Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm new in this forum, also in Linux world.
I have an issue with Ubuntu Server 9.13 VM.
I have on this server Docker and Rancher containers.
I would like to start
Code:
sudo service ssh start
and i get the following error message:
Code:
ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
Active: failed (Result: timeout) since Tue 2023-07-11 15:08:00 CEST; 1 day 21h ago
Process: 19181 ExecStart=/usr/sbin/sshd -D $SSHD_OPTS (code=exited, status=255)
Process: 19177 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
Main PID: 19181 (code=exited, status=255)
CPU: 50ms
Jul 11 15:06:29 dev systemd[1]: Starting OpenBSD Secure Shell server...
Jul 11 15:06:30 dev sshd [19181]: Server listening on 0.0.0.0 port 2222.
Jul 11 15:06:30 dev sshd [19181]: error: Bind to port 2222 on :: failed: Address already in use. Jul 11 15:06:30 dev sshd [19181] Generating 768 bit RSA key.
Jul 11 15:06:30 dev sshd [19181]: RSA key generation complete.
Jul 11 15:08:00 dev systemd[1]: ssh.service: Start operation timed out. Terminating.
Jul 11 15:08:00 dev systemd[1]: ssh.service: Main process exited, code=exited, status=255/n/a
Jul 11 15:08:00 dev systemd[1]: Failed to start OpenBSD Secure Shell server.
Jul 11 15:08:00 dev systemd[1]: ssh.service: Unit entered failed state.
Jul 11 15:08:00 dev systemd[1]: ssh.service: Failed with result 'timeout'.
What i already tried:
- changed the port to different port numbers. None of them worked.
- i used this command to check which port is listening:
Code:
netstat -tunlp
. But port 2222 is not include in the list.
- I checked all the container ports, but none of them using this port.
- restarted the whole server, nothing changed
Any idea what is the problem could be?
Should i reinstall the whole ssh and sshd service?
Thank you!
Last edited by martonstark; 07-13-2023 at 08:26 AM.
just a remark, there is no ubuntu 9.13, I don't know what is it.
Yes, you need to check why is it already in use. Probably you tried to start that service two times somehow.
just a remark, there is no ubuntu 9.13, I don't know what is it.
Yes, you need to check why is it already in use. Probably you tried to start that service two times somehow.
Ubunru 9 seems to be quite old. According to https://wiki.ubuntu.com/Releases it's End of Life as of April 30, 2011. Are you sure it's Ubuntu ? You would be running 12 years old OS
Don't use Ubuntu myself. however it's a fork of Debian and I run into similar problem on Debian a couple of years ago. Could have been Debian 9 at the time.
Test your ssh configuration with
Code:
sshd -t
from man sshd
Quote:
-T Extended test mode. Check the validity of the configuration file, output the effective configuration to stdout and then exit. Optionally, Match rules may be applied by
specifying the connection parameters using one or more -C options.
-t Test mode. Only check the validity of the configuration file and sanity of the keys. This is useful for updating sshd reliably as configuration options may change.
In my case I was getting "Missing privilege separation directory: /var/run/sshd"
The below is from my notes taken about 6 years ago:
create that missing directory, and try above start-stop-daemon command again:
Code:
mkdir /var/run/sshd
chmod 0755 /var/run/sshd
directory /run is ephemeral and destroyed on each reboot, so this needs to be recreated
Code:
vi /usr/lib/tmpfiles.d/sshd.conf
Make sure content is as follows ( for some reason it will not create in /var/run which is a symlink to /run )
Ubunru 9 seems to be quite old. According to https://wiki.ubuntu.com/Releases it's End of Life as of April 30, 2011. Are you sure it's Ubuntu ? You would be running 12 years old OS
Don't use Ubuntu myself. however it's a fork of Debian and I run into similar problem on Debian a couple of years ago. Could have been Debian 9 at the time.
Test your ssh configuration with
Code:
sshd -t
from man sshd
In my case I was getting "Missing privilege separation directory: /var/run/sshd"
The below is from my notes taken about 6 years ago:
create that missing directory, and try above start-stop-daemon command again:
Code:
mkdir /var/run/sshd
chmod 0755 /var/run/sshd
directory /run is ephemeral and destroyed on each reboot, so this needs to be recreated
Code:
vi /usr/lib/tmpfiles.d/sshd.conf
Make sure content is as follows ( for some reason it will not create in /var/run which is a symlink to /run )
Code:
d /run/sshd 0755 root root
Thank you. I tried the
Code:
sshd -t
and with -T but there was no output.
Also I tried the solution what you had before, and the result is remaind almost same.
Code:
Unit ssh.service has begun starting up.
Ul 14 14:24:5¢ dev sshd[5269]: error: Bind to port 2222 on 0.0.0.0 failed: Address already in use.
ul 14 14:24:54 dev sshd[5269]: error: Bind to port 2222 on :: failed: Address already in use.
Ul 14 14:24:54 dev systemd[1]: ssh.service: Main process exited, codesexited, status=zss/n/a
ul 14 14:24:5¢ dev sshd[5269]: fatal: Cannot bind any address.
ul 14 14:24:5¢ dev systemd[1]: Failed to start OpenBSD Secure Shell server.
- Subject: Unit ssh.service has failed
- Defined-By: systemd
- Support: https://www.debian.org/support
- Unit ssh.service has failed.
- The result is failed.
Ul 14 14:24:5¢ dev systemd[1]: ssh.service: Unit entered failed state.
Ul 14 14:24:54 dev sistemd[i]: ssh.service: Failed with result 'exit-code'.
6553 ? Ss 0:00 runsv sshd
10303 7 s 0:00 /usr/shin/sshd
23170 7 B 0:00 sshd: /usr/shinssshd -D -f /assets/sshd_canfig -e[listener] 0 of 100-200
startups
I trimmed your 'ps' output, you have three sshd instances already running. Also, 'runsv' is part of the runit init system, yet your logs show systemd info. This is bound to cause issues much larger than this one daemon not starting.
I'm not sure what that last sshd is: "/usr/shinssshd -D -f /assets/sshd_canfig -e[listener] 0 of 100-200" or "/usr/shin/sshd", which seems like a typo and should be '/usr/sbin/sshd'.
Last edited by thinknix; 07-14-2023 at 09:52 AM.
Reason: spelling
I trimmed your 'ps' output, you have three sshd instances already running. Also, 'runsv' is part of the runit init system, yet your logs show systemd info. This is bound to cause issues much larger than this one daemon not starting.
And what i could do? Should I kill this processes? I tried that but it has been shown in the list again with new process ID.
Code:
kill <process id>
and
Code:
kill -9 <process id>
Quote:
I'm not sure what that last sshd is: "/usr/shinssshd -D -f /assets/sshd_canfig -e[listener] 0 of 100-200" or "/usr/shin/sshd", which seems like a typo and should be '/usr/sbin/sshd'.
Yes this is looks like a typo, i ran again and the pathes are fine.
no, killing them will not solve your issue at all. You need to find out why did they start (and how). And obviously you only need one of them, the others can be stopped/disabled/removed/fixed.
maybe your situation is that there is also a different problem that keeps sshd running even if it does not work as intended. if you reboot, it would start 1st sshd and fail to work as expected for a different reason while continuing to run. then starting it again is hitting the busy port problem because the 1st one is still listening on that port. ultimately, you need to first solve why the port stays busy ... what the other problem is.
what i would do is change the configuration so that sshd does not get started automatically at all. that way i only need to reboot once and can manually start sshd to test changes without a reboot each time. then once i have it working OK, change it back to automatic start and do one more reboot to be sure the fix really works on boot up.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.