31

I have a linux computer acting as a server which can accept incoming SSH connections.

Is it possible to reliably connect multiple devices at the same time, such as my phone and laptop, as well as other desktops, to the same server using SSH?

Thanks for the help.

3
  • 70
    Why didn't you just try before asking? Jan 28, 2016 at 8:01
  • 2
    Not only this, but you can have multiple links between the same pair of systems. You may also find screen or mosh useful if you want the "Windows remote desktop" behaviour for the command line: a single interface which is passed around multiple links.
    – pjc50
    Jan 28, 2016 at 16:58
  • 13
    There are 2 reasons why I didn't simply try before asking; the first is the lack of faith I have in my own understanding of linux - if it had worked I would have still not trusted its reliability if I come to rely on it. The second is the the Superuser community is, generally speaking, awesome and quick to help those who ask - thanks community.
    – Unencoded
    Jan 28, 2016 at 17:40

4 Answers 4

62

The short answer - Yes. It usually works by default.

The long answer - Depending on what you are using it for, it may slow down with multiple connections, but that is a bandwidth issue, not an ssh issue.

0
31

Yes it is possible, it is the default behaviour.

Trust

You can rely if you are using an updated version of ssh and the protocol is not any more 1.

grep "Protocol"  /etc/ssh/sshd_config

The command above should give you Protocol 2.

Limits for the connections

You can see ssh as the encrypted evolution of telnet, born in the far '69 to allow remote access to a server. Note that ssh connects over TCP and it is able to forward X-sessions (graphical session) too. Multitasking and multi-user are in the inner nature of Unix... even if it is not without limits !!!

You can see some of those limits in the TCP and SSH limits:

  • cat /proc/sys/net/core/somaxconn, usually 128, to see the maximum TCP outstanding connection you can have;

    The kern.ipc.somaxconn sysctl(8) variable limits the size of the listen queue for accepting new TCP connections. The default value of 128 is typically too low for robust handling of new connections on a heavily loaded web server.

  • cat /proc/sys/net/core/netdev_max_backlog, usually 1000, the maximum length of the TCP packet queue
  • less /etc/security/limits.conf you can find the limits for user.
  • MaxSessions in /etc/ssh/sshd_config

    MaxSessions Specifies the maximum number of open sessions permitted per network connection. The default is 10.

  • #MaxStartups 10:30:60 usually commented in the /etc/ssh/sshd_config and by default set to 10

    Specifies the maximum number of concurrent unauthenticated connections to the SSH daemon... The default is 10.


References

  • man ssh, man sshd on your machine.
  • The man page of sshd or of sshd_config.
4
  • 5
    somaxconn is the maximum number of outstanding connections, i.e. the maximum listen backlog, not the 'maximum number of TCP connection[s] you can have'. The maximum number of TCP connections you can have is orders of magnitude larger than 128. Otherwise practical servers would not be possible.
    – user207421
    Jan 29, 2016 at 3:28
  • @ejp thanks for the spot, I was on hurry and I misses "new" before connection. BTW "outstanding" is more precise. I added some words more in the hope it is more clear.
    – Hastur
    Jan 29, 2016 at 6:43
  • MaxSessions only limits the number of multiplexed sessions over a single TCP connection (more details) so it doesn't limit you to connect to the same host again. (A default limit of 10 for total ssh sessions would be absurd. imagine a shared webhost with hundreds or thousands of user accounts and only 10 ssh sessions allowed.)
    – Josef
    Jan 29, 2016 at 8:49
  • @Josef It is written MaxSessions Specifies the maximum number of open sessions permitted per network connection, nothing different (as reported in the man page): maybe not clear enough. Thanks for the additional reference and to underline this point. (Note: BTW the common use of a Linux computer with ssh is not a shared web host with 10^5+ users account, and in that case the default setting cannot be appropriate by definition :-) )
    – Hastur
    Jan 29, 2016 at 11:36
5

Yes, it totally is. But this should be implementation-defined. You could as well program your own (probably not so secure, and worse) ssh server that cannot handle multiple connections. But just like common HTTP-Servers of course support this, openssh does so too.

Actually this is the very concept of Unix: A multiuser system where a server does all the work and only small clients connect (terminals).

0
4

Yes, this is very common. Indeed if used as a fileserver and by many users it is absolutely essential. SFTP uses SSH, and there is a lot of EDI activity that depends on it too.

From devices it is possible to trigger events with custom user logons (such as poweroff or reboot).

Consider also SCP (WinSCP is commonly used to access source code), and KDE users still able to use fish: in Konqueror.

Notable too is the use of additional ports in case of loss during maintenance (Ubuntu do-release-upgrade, say).

So yes, I gather you have never had multiple PuTTY terminals open ?

2
  • No strangely enough I hadn't! But thank you for the extra information, what did you mean about additional ports for maintenance?
    – Unencoded
    Jan 29, 2016 at 14:30
  • 1
    During do-relesase-upgrade from a remote terminal, there is a risk that comms will be lost (restart of SSH or network, say). If these cannot be re-established on port 22 Ubuntu provides an alternative port 1022 using a second SSH instance. The update occurs inside "screen" which can be accessed with screen -x / screen -r after reconnecting and a sudo su. (look into "screen" and "tmux"). Plenty of information around on this.
    – mckenzm
    Jan 31, 2016 at 3:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .