Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
58  
Why didn't you just try before asking? – Dmitry Grigoryev Jan 28 at 8:01
1  
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 at 16:58
6  
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. – Sam3000 Jan 28 at 17:40
up vote 46 down vote accepted

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.

share|improve this answer

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.
share|improve this answer
1  
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. – EJP Jan 29 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 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 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 at 11:36

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).

share|improve this answer

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 ?

share|improve this answer
    
No strangely enough I hadn't! But thank you for the extra information, what did you mean about additional ports for maintenance? – Sam3000 Jan 29 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 at 3:01
    
Brilliant, thank you for the information – Sam3000 Jan 31 at 16:45

protected by JakeGould Jan 29 at 2:59

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.