0

I have /root/.ssh folder with authorized_keys file inside of it with client public key. Root logs in fine without password by using ssh.

In case I do login with another user system reject key and asks for password.

How to setup ssh key login for simple user?

vico
  • 4,527
  • 21
  • 58
  • 87

1 Answers1

2

You need to be careful with permissions:

  1. Create ~/.ssh:

    $ mkdir ~/.ssh
    
  2. Create ~/.ssh/authorized_keys:

    $ touch ~/.ssh/authorized_keys
    
  3. Make sure you have the right permissions:

    • Home directory on the server should not be writable by others:

      $ chmod go-w ~
      
    • SSH folder on the server needs 700 permissions:

      chmod 700 ~/.ssh
      
    • Authorized_keys file needs 644 permissions:

      chmod 644 ~/.ssh/authorized_keys
      
  4. Add your key to ~/.ssh/authorized_keys. You can either add it manually or use

    $ ssh-copy-id user@host
    

References:

[1] https://superuser.com/questions/215504/permissions-on-private-key-in-ssh-folder

[2] How do I add SSH Keys to authorized_keys file?

Melebius
  • 11,431
  • 9
  • 52
  • 78