Ubuntu – SSH user1@ip_address: Permission denied (publickey)

networkingpermissionsserverssh

I am trying to connect to a my SSH server (running on Ubuntu 16.04.2 LTS) from my local machine (Ubuntu 18.04.03 LTS).

I have created a private and public key on my local machine and copied my public key to my SSH server's authorized_keys file.

I could log in with ssh root@ip-address and I have access (as root user), but when I tried to log in as another user with command ssh name@ip-address, it generated an error message:

name@ip_address: Permission denied (publickey)

What can I do so the name@ip-address could be accessed?

Best Answer

Step 1: Open sshd_config file

sudo nano /etc/ssh/sshd_config

Step 2: Change the following lines

PermitRootLogin prohibit-password to PermitRootLogin yes 
PasswordAuthentication no to PasswordAuthentication yes

Step 3:restart ssh service:

sudo service ssh restart