On localhost running sshd service. Created two pairs of rsa keys for
user1 using ssh-keygen. Copied from root/.ssh/id_rsa.pub to user1/.ssh/id_rsa.pub. Changed permissions to 600. Tried
ssh -l user1 localhost and
ssh -l root localhost but both failed with Permission denied (publickey,keyboard-interactive).. Do I have to copy public key to
~/.ssh folder for both users? What is wrong with configuration? Why I cannot connect to localhost?
RSAAuthentication yes PubkeyAuthentication yes PasswordAuthentication yes UsePAM no AllowUsers user1 root PermitRootLogin yes
/etc/ssh/ssh_config is uncommented lines:
RSAAuthentication yes PasswordAuthentication no ForwardX11 no SendEnv LANG LC_* HashKnownHosts yes GSSAPIAuthentication yes GSSAPIDelegateCredentials no PubkeyAuthentication yes
I am trying to connect to localhost. I have to be able to login to user1 using only public key while possible to login as root with public key and/or password.
cp ~/.ssh/id_rsa.pub /home/user1/.ssh/authorized_keys. Changed permissions
chmod -R 700 ~/.ssh and
chmod -R 700 /home/user1/.ssh. Restarted sshd 'service ssh restart'. But it seems not working.
root@ubuntu:~# ssh-copy-id user1@localhost The authenticity of host 'localhost (127.0.0.1)' can't be established. ECDSA key fingerprint is 34:29:b6:1b:fe:84:eb:82:85:77:87:f6:25:39:61:5a. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts. Permission denied (publickey,keyboard-interactive). root@ubuntu:~# ssh-copy-id root@localhost Permission denied (publickey,keyboard-interactive).
# tail /var/log/auth.log ... ubuntu sshd: User root not allowed because account is locked
A good SSH troubleshot article: Problems and Solutions