0

After getting disconnected from the server (Ubuntu 18.04.1) I can not login anymore using public key.

I have 2 accounts that can run sudo. One account uses public key and a passphrase to login, and the other uses a password. Both accounts have existed for a long time and worked flawlessly. Now I have got a problem with the account that uses public key. When I try to login, i always get a question about passphrase, but that question is gone, and I get : "Permission denied (publickey)" without ssh asking for a passphrase. I have tried rebooting my client, but that does not help. I have rebooted my server and that does not help either. What helps, is if I use the other account (User2) that uses a password instead of a key and login to the server and disable the following rows in my sshd_config and and run "sudo service ssh restart":

#Match User User1
#PasswordAuthentication no

Then logout and run ssh [email protected]. Now I will be asked for a password and not a passphrase and then I will be logged in. If I then change the ssd_config back to

Match User User1
PasswordAuthentication no

and and run "sudo service ssh restart"

I will be able to use user1 to login and I will be prompted for a passphrase, so everything works.

This will work fine until the connection disconnects due to inactivity or i reboot my server (which will generate a disconnect). After that I have to repeat all steps above.

I have tried connecting from two different clients, one running Linux Mint and the other raspbian, the problem is the same.

I have also tried ssh -i .ssh/id_rsa [email protected] and the result is the same "Permission denied (publickey)"

1 Answer 1

0

Your question is not clear but let me try to answer based on what I understood

You have 2 user... assuming ‘user1’ ‘user2’

If user1 needs to access user2 try copying the id_rsa.pub to user2 authorised_keys

Goto

cd .ssh
ls
cat id_rsa.pub

Copy the key

Then login user2

cd .ssh
ls
sudo nano authrized_keys

Paste the key you copied from id_rsa.pub

Then try connecting user2 from user1, you should be able to connect user2 without running into any issue

it should work...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .