Guide to getting SSH working?


VizeL

Recommended Posts

Is there any guide to getting SSH working? I don't believe my daemon is running, and when I tried manually running it (/etc/rc.d/rc.sshd) it tells me

key_load_public: invalid format

Could not load host key: /etc/ssh/ssh_host_rsa_key

key_load_public: invalid format

Could not load host key: /etc/ssh/ssh_host_dsa_key

key_load_public: invalid format

Could not load host key: /etc/ssh/ssh_host_ecdsa_key

key_load_public: invalid format

Could not load host key: /etc/ssh/ssh_host_ed25519_key

Disabling protocol version 2. Could not load host key

sshd: no hostkeys available -- exiting.

 

I tried moving the generated keys from /boot/config/ssh to /etc/ssh but that didnt work either.

Link to comment
  • 1 year later...

Okay, so I ran into a similar issue, found this post when googling, and normally I don't like to resurrect dead posts but I figured I'd round out the answer for future users who may find it helpful.

 

On 9/16/2015 at 5:53 PM, ken-ji said:

Your current host keys might be corrupt.

delete them with

 


rm /etc/ssh/ssh_host_*key* /boot/config/ssh/ssh_host_*key*
 

 

then start sshd with

 


/etc/rc.d/rc.sshd start
 

 

This works. When you start sshd it will generate keys appropriately. The problem is that it's storing them in /etc/ssh/, which isn't preserved across reboots.

 

The solution is to move the newly generated keys to the flash drive, where unraid will copy them into their proper location as part of its booting process.

 

cp /etc/ssh/ssh_host_*key* /boot/config/ssh/

I tested by rebooting and sshing after I did this copy command and it does indeed work, but I didn't test before copying the keys so if unraid auto copies the keys on shutdown or anything like that and my advice is redundant I apologize, but I know for a fact this works.

Link to comment
Quote

sshd_start() {
  # make sure ssh dir exists on flash
  mkdir -p /boot/config/ssh
  # restore saved keys, config file, etc.
  cp /boot/config/ssh/* /etc/ssh &>/dev/null
  chmod 600 /etc/ssh/* &>/dev/null

  # Create host keys if needed.
  ssh-keygen -A

  # copy any new/generated key back to flash drive
  cp /etc/ssh/ssh_host*_key* /boot/config/ssh/

  /usr/sbin/sshd
}

 

Its redundant... :D the snippet above is from the /etc/rc.d/rc.sshd script

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.