GoAdmio

ssh

Rebuild /etc/ssh/sshd_config from GoAdmio's settings (port, root login, shell accounts, chroot), or restart the SSH service

On this page: Overview · Quick start · Syntax · Options · Output · Examples · Troubleshooting · Details · See also


Overview

/go/ssh writes the SSH server's configuration file, /etc/ssh/sshd_config, from scratch, using the settings stored in GoAdmio, and then restarts the SSH service. This keeps the SSH setup consistent with what you set in GoAdmio:

With the restart argument, it only restarts the service.

[!WARNING] The file is rewritten completely every time. Changes you made to sshd_config by hand are lost, and the new file is not tested before SSH restarts. Keep a second SSH session open while you run it.


Quick start

# Rebuild the configuration and restart SSH
/go/ssh

# Only restart SSH
/go/ssh restart

Syntax

/go/ssh
/go/ssh restart
/go/ssh --serversync

Options

Argument Effect
(none) Rebuilds sshd_config and restarts SSH.
restart Restarts SSH without changing the configuration.
--serversync Rebuilds the configuration with much higher connection limits, for moving a server (see serversync).

The limits that --serversync changes:

Setting Normal With --serversync
MaxSessions 10 250
MaxStartups 10:30:100 250
MaxAuthTries 6 100
ClientAliveInterval 0 60
ClientAliveCountMax 3 5

Output

The command prints nothing. Every run is logged to /var/log/go/ssh.log with a timestamp and the arguments used.

Outcome Exit status
restart 0
Rebuild The status of the final restart.

The service that is restarted is ssh on Ubuntu and sshd on other systems.


Examples

# Rebuild the configuration
/go/ssh
# Restart only
/go/ssh restart
# Higher limits while migrating a server
/go/ssh --serversync
# Test the configuration without restarting
sshd -t

Troubleshooting

Symptom Likely cause Fix
You are locked out after running it The new configuration is invalid, or the port changed and the firewall doesn't allow it. Log in through the provider's console. Restore the original file with cp /etc/ssh/sshd_config.bak /etc/ssh/sshd_config, then restart SSH. Next time, test with sshd -t first.
Your own SSH settings disappeared The file is rewritten on every run. Put the setting in GoAdmio's configuration instead, or edit the script. Files in sshd_config.d/ can't override the settings the command writes, because the main file is read first.
root can't log in The root login setting in GoAdmio is off. Allow it for specific IP addresses with permitrootlogin.
SSH is on a different port than 22 The port comes from the SSH port setting in GoAdmio. Check the setting. See port. Open the port in the firewall.
A hosting account can't get a shell Accounts without a shell are chrooted to their home folder. Enable the shell for the account (see shell and jailedshell).
An account with a shell is still chrooted The exclusion list is built from the account domains, so an account whose username differs from its domain isn't excluded. Check the Match User line at the end of sshd_config.
Many parallel sessions fail during a migration The normal limits are too low. Run /go/ssh --serversync, and /go/ssh again afterwards.
Include /etc/ssh/sshd_config.d/*.conf is missing The original file (sshd_config.bak) didn't have it. Add it by hand if you need it.

Details

Backup

The first time the command runs, it copies the existing sshd_config to sshd_config.bak. This is the file from before GoAdmio first rewrote it. It is never replaced afterwards. The command also reads it to decide which optional lines to carry over.

What is written

In this order:

  1. Port <port>, from GoAdmio's SSH port setting (22 if it is empty or 0)
  2. the five limits shown above
  3. SyslogFacility AUTHPRIV
  4. PermitRootLogin yes or no, from GoAdmio's setting (no if the setting is missing)
  5. AuthorizedKeysFile .ssh/authorized_keys
  6. PasswordAuthentication yes, ChallengeResponseAuthentication no, GSSAPIAuthentication yes, GSSAPICleanupCredentials no, UsePAM yes
  7. X11Forwarding yes, PrintMotd no, AcceptEnv LANG LC_*
  8. Subsystem sftp internal-sftp
  9. Lines carried over from the original file, if it had them: Include /etc/ssh/sshd_config.d/*.conf, the AWS Lightsail TrustedUserCAKeys line, and CASignatureAlgorithms +ssh-rsa
  10. A Match User block that puts every account except root, go, the GoAdmio SSH user, and the accounts that have a shell into a ChrootDirectory %h (their home folder). It is skipped if the GoAdmio SSH user isn't known.
  11. A Match Group Jailed block for jailed shell accounts: ChrootDirectory %h, no TCP forwarding, no X11 forwarding.
  12. A Match Address block that allows PermitRootLogin yes from the IP addresses listed with permitrootlogin, if there are any.

Then it restarts the SSH service.

Files and requirements

Item Used for
/etc/ssh/sshd_config, sshd_config.bak The configuration and its first backup.
/usr/local/goadmio/include/config/config.php The GoAdmio SSH user name.
/var/lib/sqlite/config.db The SSH port and the root login setting.
/var/lib/sqlite/site.db The accounts that have a shell.
/var/lib/sqlite/ssh.db The IP addresses allowed to log in as root.
/var/log/go/ssh.log The command log.

Security notes


See also

Command Description
port Change the default SSH port (22) to another port
permitrootlogin Allow root SSH login from a specific IP
shell Enable or disable SSH shell access for an account
jailedshell Enable or disable a chrooted SSH shell for a domain
installssh Reinstall and enable the OpenSSH server
sshtop Report top SSH brute-force sources and optionally block them
fail2ban Install and configure Fail2ban to ban brute-force sources
dropbear Install Dropbear in GoAdmio
serversync Back up and migrate a GoAdmio server with all configurations
heal Check GoAdmio service status and fix issues