SSH To My Additional Non root user - Please help...

September 22, 2017 239 views
Security Deployment DigitalOcean Ubuntu 16.04

Hi all,

I am new to setting up a vps and would be grateful if someone could advise me on the following please:

I have read the setting up a vps beginners tutorial and I have understood how to log in to root via ssh keys. I have added ssh key in digital ocean portal and that all seemed to work fine.

I can log in via putty to root without any password

My problem is when adding a new user:

I can add the user fine, but adding ssh keys to the new sudo user is were iam stuck.

  1. How do I do this? Step by step would be helpful? 2.Can I use putty to log in to this new user or do i still need to log in as root and then login as new user? 3.Can I create a new private and public key in puttygen? 4.do i use the same ssh key that I use for root?

Thanks in advance

Colin

1 Answer

Hi Colin,

Which server do you use? Ubuntu ?
For now I will assume it is a Linux based server.

since you are using putty and also have putty gen installed you can create a key pair with puttygen.

Login to your new user account or switch to it from within your root login (# su newuser)

a) Create .ssh directory and apply proper permissions
# mkdir ~/.ssh && chmod 700 ~/.ssh

b) Create the file to store your public get in and apply permissions
# touch ~/.ssh/authorizedkeys && chmod 600 ~/.ssh/authorizedkeys

c) From your puttygen window right click on the public key string select all and copy. Make sure to safe the private key to your computer

d) Back to your console edit the authorizedkeys file and paste your public key into it
# vi ~/.ssh/authorized
keys

e) Either point to the private key within putty or launch pagent and load your private key in.

Note: With the pagent running you don't need to reference the private key within your putty session. just ip and user.

f) Use putty and login using your new user name instead of root

This should do it, sir.

Have another answer? Share your knowledge.