Permission denied (publickey,password). while using ssh to login
Solution 1
If you get Permission denied
while using ssh to login, you probably need to edit the /etc/ssh/sshd_config
file.
Change PasswordAuthentication
value to yes
.
PasswordAuthentication yes
Solution 2
If you are not using ssh public key, and you just forget your root password, you can reset your root password using Digital Ocean control panel
If you are using ssh public key and you forget the password to that key, you can force SSH to use your Digital Ocean password instead of the key
ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no user@host
Solution 3
I faced a similar problem while trying to ssh into another machine. These steps helped me to get to a solution:
1 -- sudo passwd root
- Change root password (optional)
2 -- sudo install openssh-server
3 -- cd /etc/ssh
4 -- sudo nano sshd_config
(Now uncomment line PermitRootLogin and change it to yes,
Uncomment Authorized keys file,
Uncomment PasswordAuthentication and change it to yes)
5 -- sudo systemctl restart ssh
Now you are good to go, and can easily connect over ssh using the root account.
6 -- su -
7 -- ssh root@ip-of-device
EgzEst
Updated on June 16, 2022Comments
-
EgzEst almost 2 years
I'm trying to login to the server using ssh, and I realise that I forgot my password. I'm using this command:
ssh [email protected]
I don't know what to do, I searched for a solution but nothing helped me. I'm using Ubuntu 14.04. Any help?
-
EgzEst about 8 yearsshould I replace user and password? Sorry for my question, but I'm a little confused
-
Xiongbing Jin about 8 yearsThe password that you forgot was only for that key file. You can totally delete the key file if you don't think you'll ever remember it (it's inside
.ssh
folder in your home folder), and then you can remove the corresponding public key from the remote server, and replace it with a new one if you like. -
Xiongbing Jin about 8 yearsI clarified my answer. If you simply forget the root password to this server, you can reset it in your Digital Ocean control panel.
-
Jekis over 3 yearsAnd don't forget to restart ssh after that:
sudo service ssh restart
-
bmello about 3 yearsThis must be done on the server or on the client?
-
IsaacE about 3 yearsThe configuration is done at the server and also the service restart