What you see
The login works, then the terminal shows Connection closed or Connection lost within a few seconds.
Why it happens
- The account has no shell, such as
/usr/sbin/nologin, or the server runs one fixed command and closes. - A command in the startup files of the shell, such as
exitin.bashrc, ends the session. - The startup command saved in the server's settings ends the session.
- Some routers, switches and firewalls accept only one channel per connection.
What to do
- Check the shell of the account on the server:
The last field is the shell. It must be a real shell such asgetent passwd deploy/bin/bash. - Open the server and choose Show more. Under At startup, set Startup command to None.
- For a router, switch or firewall, open the server, choose Show more, then Connection, turn off Automatic commands and connect again.
- On a server you manage, allow more sessions per connection in
/etc/ssh/sshd_config, then restart SSH:MaxSessions 10
With OpenSSH you can see where the session ends:
ssh -v deploy@203.0.113.10