Secure SSH


Dr_Cox1911

Recommended Posts

Hi guys,

 

I'm currently planning my switch from Debian to unRaid and thus gathering some info on how to securely set things up.

With Debian I used a rather safe mechanism consisting of key-based login with a user that has only rights to switch to other users and ssh. So I logged into this user with my key-file and then su'ed to the other user I needed.

 

Is something similiar possible with unRaid? Is it as simple as doing the exact same steps as with Debian? Anything special regarding future updates of unRaid?

Link to comment

What exactly are you trying to accomplish?

 

unRAID is not debian. It isn't really even a full-blown implementation of slackware.

 

unRAID is a NAS, a host for VMs, and a host for dockers. All of that can usually be managed from the webUI. Some people do a little bash scripting, usually for additional file management, etc. But working at the command line isn't the usual way of using unRAID.

Link to comment
  • 1 month later...

I personally added SSH keys to my root account by creating the keys normally (I had to create the ed25519 keys off-system. I forget exactly why creating them on-system wasn't working...) and putting them in /boot/config/ssh/ then I modified my /boot/config/go file (which is run during every boot) to copy the files over and set the permissions by adding the following:

 

mkdir /root/.ssh
cp /boot/config/ssh/authorized_keys /root/.ssh/authorized_keys
cp /boot/config/ssh/id_ed25519 /root/.ssh/id_ed25519
cp /boot/config/ssh/id_ed25519.pub /root/.ssh/id_ed25519.pub
cp /boot/config/ssh/id_ed25519 /root/.ssh/id_rsa
cp /boot/config/ssh/id_ed25519.pub /root/.ssh/id_rsa.pub
chown root:root /root/.ssh -R
chmod 700 /root/.ssh
chmod 600 /root/.ssh/authorized_keys
chmod 600 /root/.ssh/id_ed25519
chmod 644 /root/.ssh/id_ed25519.pub
chmod 600 /root/.ssh/id_rsa
chmod 644 /root/.ssh/id_rsa.pub

 

You'll also want to make sure /boot/config/ssh/sshd_config has passwords disabled and your keys set up. Actually, come to think of it, that go bit probably isn't even necessary if you just set up sshd_config to use the files in /boot/config/ssh/

Link to comment
4 hours ago, bamhm182 said:

I personally added SSH keys to my root account by creating the keys normally (I had to create the ed25519 keys off-system. I forget exactly why creating them on-system wasn't working...) and putting them in /boot/config/ssh/ then I modified my /boot/config/go file (which is run during every boot) to copy the files over and set the permissions by adding the following:

 


mkdir /root/.ssh
cp /boot/config/ssh/authorized_keys /root/.ssh/authorized_keys
cp /boot/config/ssh/id_ed25519 /root/.ssh/id_ed25519
cp /boot/config/ssh/id_ed25519.pub /root/.ssh/id_ed25519.pub
cp /boot/config/ssh/id_ed25519 /root/.ssh/id_rsa
cp /boot/config/ssh/id_ed25519.pub /root/.ssh/id_rsa.pub
chown root:root /root/.ssh -R
chmod 700 /root/.ssh
chmod 600 /root/.ssh/authorized_keys
chmod 600 /root/.ssh/id_ed25519
chmod 644 /root/.ssh/id_ed25519.pub
chmod 600 /root/.ssh/id_rsa
chmod 644 /root/.ssh/id_rsa.pub

 

You'll also want to make sure /boot/config/ssh/sshd_config has passwords disabled and your keys set up. Actually, come to think of it, that go bit probably isn't even necessary if you just set up sshd_config to use the files in /boot/config/ssh/

Yeah all you really needed to do is modify /boot/config/ssh/sshd_config to:

  • read authorized keys from /etc/ssh or /boot/config/ssh (as /boot/config/ssh/* gets copied to /etc/ssh upon startup of the ssh server

And for bonus points, you probably want to modify ssh_config to read the default private keys from /etc/ssh as well.

Link to comment
  • 1 month later...

Is there some kind of implementation for limiting the numbers of failed ssh password attempts and maybe ban an IP from trying anymore?

I fall over this little article/guide on using a tool called fail2ban, this is listing for failed ssh attempts and permanently ban them from trying any more :-D

 

This seems like a feature that we really need, as he states in the post; 

Quote

And you should be good to go! Just this morning I’ve brought the banhammer down on IPs from the Russian Federation, The Netherlands, Islamic Republic of Iran, and China.

 

 

I just mean, why would anyone from China need to ssh into my server for other things than to do something evil?

Link to comment

but the process of setting up the key seems a bit much for some people. And then U have to backup the key somewhere, and if U are on the road, and forgot or dropped the usb stick then U are in very bad luck. And that fail2ban method seems so easy to implement if u don't want the long process of setting up an ssh key and storing it somewhere safe.

 

Best regards,

Brydezen 

Link to comment

fail2ban is included in the let's encrypt docker.  So I guess you could use that and just create a jail for unraid log, create a voulme mapping to the unraid syslog and put the logpath in the jail config. Should work. There's probably several fail2ban dockers on dockerhub too. But I agree key based login is still the way to go IMO. If you want to use fail2ban you still have to configure it, set up jails etc, which means editing config files. And people who can figure out how to do that can probably set up key based login too if they put their mind to it.

Edited by strike
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.