2

I just recently started a VPS using Fedora. Upon creation of the VPS I was asked if I wanted to use SSH keys (which I did). Now, to connect as root to the VPS, I do not need to enter a password.

Now I want to create a pair (or just reuse the same key) for user1 for use while using ssh. First I tried to paste the id_rsa.pub folder while logged in as user1 in the ~/.ssh/ folder.

  • Still asks for password upon ssh

Then I added a authorized_keys file that was identical to the id_rsa.pub file.

  • Still asks for password upon ssh

Then I chmod the permissions to the .ssh folder to 644 however, when I try to ssh login as user1.

  • Still asks for password upon ssh

How can I use the same public ssh key on a user account that I have for the root account. Where to I put these files, and what is the difference between having a id_rsa.pub file and an authorized_keys file?

Startec
  • 1,839
  • 4
  • 24
  • 27
  • 3
    [Have you checked all the permissions?](http://unix.stackexchange.com/questions/16978/how-to-make-password-less-login-work) The `.ssh` directory must be 700 (`drwx------`), the `authorized_keys` file must be 644 or 640 or 600 (`-rw-r--r--` or `-rw-r-----` or `-rw-------`), and your home directory must not be group-writable. If you can't figure out whether the permissions are correct, post the output of `ls -ld ~ ~/.ssh ~/.ssh/authorized_keys` on the server and `ls -ld ~ ~/.ssh ~/.ssh/id_rsa` on the client. – Gilles 'SO- stop being evil' Apr 10 '15 at 00:18
  • This is correct. I did have appropriate permissions on the `.ssh` directory. That fixed it. Also, can you tell me what file actually gets checked? is it the `authorized_keys` or the `id_rsa.pub` file? – Startec Apr 10 '15 at 00:22
  • The `id_rsa.pub` file is never read by `ssh` (but it's useful to keep it around to easily determine where a public key is coming from). The server reads `authorized_keys` and the client needs `id_rsa`. – Gilles 'SO- stop being evil' Apr 10 '15 at 00:29
  • when you say "to keep around" - if I set up keys on another computer I just append the key to the existing `id_rsa.pub` and `authorized_keys` files correct? Is `ssh` somehow able to parse the files to read the different keys? – Startec Apr 10 '15 at 00:39
  • 1
    The SSH server reads `authorized_keys`. To authorize multiple keys, just append the `.pub` files to it. Each line in that file represents one authorized key. – Gilles 'SO- stop being evil' Apr 10 '15 at 00:41

1 Answers1

1

You can use the option -i to specify to ssh which identity file it should use.

Also have you checked with ssh - v what really happen? I mean the keys are really not used or are they used but doesn't match?

statox
  • 237
  • 1
  • 15