0

I'm trying to create an SSH server Docker image that can establish multiple concurrent connections:

  • Server
> sudo /usr/sbin/sshd -Ddp 1234
  • Client 1
> ssh user@server -p 1234
user@server's password:
...
  • Client 2
> ssh user@server -p 1234
ssh: connect to host server port 1234: Connection refused

The same server machine which has an ssh-server daemon run by systemd does allow for multiple connections.

Is there a way to configure sshd to run standalone, ie. not with a service manager like systemd, or is sshd fundamentally only meant to handle a single connection and the concurrency comes from it being managed? If so, what is systemd doing to allow for concurrent connections if it's only told ExecStart=/usr/sbin/sshd -D $SSHD_OPTS (doesn't look like SSHD_OPTS is being set anywhere)?

1

I think -d gets in the way. From man 8 sshd:

sshd listens for connections from clients. […] It forks a new daemon for each incoming connection. […]

And later [emphasis mine]:

-d
Debug mode. The server sends verbose debug output to standard error, and does not put itself in the background. The server also will not fork and will only process one connection. […]

My tests indicate sshd -d behaves like you described. When I run it without -d it is able to handle multiple connections just fine.

  • I think I must have added that to solve a previous issue and not realised it had created another, I'll double check I'm actually calling the same commands in future! – inkychris May 2 at 6:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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