Pubkey ssh authentication on NAS4Free
26 Dec 2016I deployed a NAS4Free box behind a Tomato router, and wanted remote ssh access to it.
- Ensure tcp/22 is not forwarded to any untrusted subnets via your router/firewall.
- Temporarily enable password authentication in the GUI and click Save/Restart.
- Login to the NAS4Free server via ssh using
root
and your webGUI password. - Create .ssh directory and set permissions to
drwx------
(i.e. 700)mkdir .ssh
chmod 700 .ssh
- Now create the host ssh key and set it in the GUI
cd .ssh
ssh-keygen [-t dsa] -f hostkey
(accept defaults)- Open
~/.ssh/hostkey
and paste this into the Private Key field in the GUI.
- Create a client key on your client/laptop/desktop that you want to connect without password.
- Copy the public key into
~/.ssh/authorized_keys
on NAS4Free. - Ensure the permissions are set to 700 on this file
chmod 700 authorized_keys
. - Look at /etc/ssh/sshd_config and add any necessary lines. I needed to paste the following into Extra options:
RSAAuthentication yes AuthorizedKeysFile %h/.ssh/authorized_keys PubkeyAcceptedKeyTypes ssh-dss
- Click Save/Restart in GUI.
- Ensure you can login without password.
- Disable password authentication in the GUI and click Save/Restart. Your final configuration in the GUI should be as follows:
Enable Challenge-Response Authentication - No Permit root login - Yes Password authentication - No TCP forwarding - Yes Private key - paste Extra options
- Connect with an ssh client again now, without your key loaded, and confirm the login attempt is denied.