SSH login for beginners.

November 7, 2018 480 views
Linux Basics Ubuntu 16.04

I apologise for something asking something I know is well documented, but I can’t seem to get my head around this. I’ve read documentation, watched YouTube videos and followed along with Lynda all day but I’m not getting very far. I know this will take most people seconds.

I created ssh keys with puttygen. Added them to my DO and created a droplet. I can login in as root.

I want to create a new sudo and allow ssh access only. Disallow root login and have ssh login only.

I’ve tried adding new a secondary key to DO for my sudo but it won’t let me login as and the sudo user I created.

Could you please walk me through the line commands starting from logging in as root and key(s) added to my DigitalOcean account.

I know it’s just something stupid I’m doing wrong. I’ve tried generating keys via puttygen and via the terminal and I keep running into issues. When I edit the config file I see the options I should toggle/change are already in place presumably because I set my droplet up without a root password.

Should my public keys be put in the same folder or, or should each user have their public key in their own folder? Thank you!

1 Answer

You have done everything right thus far.

A strategy you can use to allow a second user access is as follows...

  1. Create the droplet, login, and setup as you have already.
  2. Create a new user adduser younewusername
  3. Provide new user with sudo privileges usermod -aG sudo yournewusername
  4. You can create and new SSH Keys, or use the one you have setup already cp -rv /root/.ssh /home/yournewusername
  5. Set owner ship to your new user chown -R /home/yournewusername/.ssh
  6. Set file permissions chmod -R 0600 yournewusername:yournewusername /home/yournewusername/.ssh/*

From here logout and log back in using yournewusername and test the sudo abilities (ie sudo apt update)

If this works, then you can proceed to lock the root account.

Have another answer? Share your knowledge.