Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSH fails sometimes to generate keys, and if it does it will fail forever #424

Closed
lesaux opened this issue Oct 18, 2017 · 9 comments
Closed

Comments

@lesaux
Copy link

lesaux commented Oct 18, 2017

Hello,

On a fresh install of octopi I found that the ssh server had all of it's ssh keys filesizes to 0.

/etc/ssh/ssh_host_* files are all at 0 bytes in size.

To see this I pulled out a keyboard and monitor.

To fix it I wiped those files and ran

sudo /usr/bin/ssh-keygen -A

On other distros this usually is included in systemctl ssh scripts.

hopes this helps others.

@guysoft
Copy link
Owner

guysoft commented Oct 19, 2017

What version of OctoPi?

@lesaux
Copy link
Author

lesaux commented Oct 19, 2017

This happened on Octopi 0.14. I am convinced that I had deployed this image earlier without facing this problem, so I will try to reproduce, and see if I can figure out how this happened.

@guysoft
Copy link
Owner

guysoft commented Oct 22, 2017

Ok, I managed to reproduce this

@guysoft
Copy link
Owner

guysoft commented Oct 22, 2017

Output of /var/log/syslog:

Sep  7 15:54:45 fullpageos systemctl[419]: Removed /etc/systemd/system/multi-user.target.wants/regenerate_ssh_host_keys.service.
Sep  7 15:54:45 fullpageos systemd[1]: Reloading.
Sep  7 15:54:46 fullpageos systemd[1]: Started Regenerate SSH host keys.
Sep  7 15:54:46 fullpageos systemd[1]: Starting Turn on SSH if /boot/ssh is present...
Sep  7 15:54:46 fullpageos systemd[1]: Reloading.
Sep  7 15:54:47 fullpageos systemd[1]: Starting OpenBSD Secure Shell server...
Sep  7 15:54:47 fullpageos systemd[1]: ssh.service: Main process exited, code=exited, status=255/n/a
Sep  7 15:54:47 fullpageos systemd[1]: Failed to start OpenBSD Secure Shell server.
Sep  7 15:54:47 fullpageos systemd[1]: ssh.service: Unit entered failed state.
Sep  7 15:54:47 fullpageos systemd[1]: ssh.service: Failed with result 'exit-code'.
Sep  7 15:54:47 fullpageos sh[433]: Job for ssh.service failed because the control process exited with error code.
Sep  7 15:54:47 fullpageos sh[433]: See "systemctl status ssh.service" and "journalctl -xe" for details.
Sep  7 15:54:47 fullpageos sh[433]: invoke-rc.d: initscript ssh, action "start" failed.
Sep  7 15:54:47 fullpageos sh[433]: ● ssh.service - OpenBSD Secure Shell server
Sep  7 15:54:47 fullpageos sh[433]:    Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
Sep  7 15:54:47 fullpageos sh[433]:    Active: failed (Result: exit-code) since Thu 2017-09-07 15:54:47 UTC; 98ms ago
Sep  7 15:54:47 fullpageos sh[433]:   Process: 454 ExecStart=/usr/sbin/sshd -D $SSHD_OPTS (code=exited, status=255)
Sep  7 15:54:47 fullpageos sh[433]:  Main PID: 454 (code=exited, status=255)
Sep  7 15:54:47 fullpageos sh[433]: Sep 07 15:54:47 fullpageos systemd[1]: Starting OpenBSD Secure Shell server...
Sep  7 15:54:47 fullpageos sh[433]: Sep 07 15:54:47 fullpageos sshd[454]: error: Bind to port 22 on 0.0.0.0 failed: Address already in use.
Sep  7 15:54:47 fullpageos sh[433]: Sep 07 15:54:47 fullpageos sshd[454]: error: Bind to port 22 on :: failed: Address already in use.
Sep  7 15:54:47 fullpageos sh[433]: Sep 07 15:54:47 fullpageos sshd[454]: fatal: Cannot bind any address.
Sep  7 15:54:47 fullpageos sh[433]: Sep 07 15:54:47 fullpageos systemd[1]: ssh.service: Main process exited, code=exited, status=255/n/a
Sep  7 15:54:47 fullpageos sh[433]: Sep 07 15:54:47 fullpageos systemd[1]: Failed to start OpenBSD Secure Shell server.
Sep  7 15:54:47 fullpageos sh[433]: Sep 07 15:54:47 fullpageos systemd[1]: ssh.service: Unit entered failed state.
Sep  7 15:54:47 fullpageos sh[433]: Sep 07 15:54:47 fullpageos systemd[1]: ssh.service: Failed with result 'exit-code'.

@guysoft guysoft changed the title cannot ssh into octopi SSH fails sometimes to generate keys, and if it does it will fail forever Oct 22, 2017
@lesaux
Copy link
Author

lesaux commented Oct 22, 2017

Great!

@guysoft
Copy link
Owner

guysoft commented Oct 23, 2017

Possible workaround in comment, but would prefer code will go in to Raspbian: RPi-Distro/pi-gen#128 (comment)

@guysoft
Copy link
Owner

guysoft commented Oct 24, 2017

Had a talk with @shift on IRC
Will implement (or will accept PR) a workaround and also if fails an output of journalctl so we can see if there is any error worth recording.

@lesaux
Copy link
Author

lesaux commented Oct 24, 2017

sounds good! Thanks for your efforts! Octopi is amazing!

@guysoft
Copy link
Owner

guysoft commented Oct 31, 2017

Fix in next nightly, there is now a log also in /var/log/regenerate_ssh_host_keys.log if this happens again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants