What I have done
- created a new digital ocean droplet and
- Created SSH key based on this guide and during the creation of the droplet I have copied it in
- I have run the following codes from here
ssh root@your_server_ip
adduser sammy
usermod -aG sudo sammy
- Than I have tried to log in as "sammy"
ssh sammy@your_server_ip
ERROR
Permission denied (publickey).
- If I log in with root access than there is no problem I get in like before
Fixes I have tried
- cleaned put the shh key folder and only have this key there
- I haven't found any answer but my problem is kind of like this
- this is not that similar to this.
ssh -vvv root@my_ip
from here it pushes out like lines of debug what should I look for?- I have tried to read sshd server logs on ubuntu this most common messages
Disconnected from invalid user somefirstname43
Disconnected from invalid user someotherfirstname334
Disconnected from authenticating user root
Received disconnect from ID port ...
Accepted publickey for root from ID
Did not receive identification string from ID port ....
Connection closed by authenticating user sammy ID port portnumber <<----
Your user sammy needs the public key you used to login to the root user. The easiest way is to copy the authorized_keys file from your root user.
There is an answer for this on Digital Ocean
1.Log in as root
ssh root@IP
2.Edit ssh config:
sudo nano /etc/ssh/sshd_config
3.Change this line:
PasswordAuthentication no
toPasswordAuthentication yes
4.Restart daemon:
sudo systemctl restart sshd
5.Do ssh-copy-id:
ssh-copy-id someuser@IP
(if you already have a key there it may not allow you to copy so just skip this step and log in with the next step)6.Log in as the new superuser you have created before
ssh someuser@IP
7.Revert changes to ssh_config if you are security conscious and restart daemon.