Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to secure my VPS, so I'm trying to use RSA authentication, obviously I don't want to be logging in as root, so I disabled PermitRootLogin but I also disabled PasswordAuthentication

My question is, how can I get my RSA key to authenticate with a regular user. Like I said, I got it to work with root while I had those settings enabled, but I have no idea how to make it work without them on, with a regular user.

PS. I'm on Ubuntu 10.04

Thanks, Archey

share|improve this question
Did you deactivate PasswordAuthentication before you had a pubkey on the server? – Baarn Jan 8 '13 at 18:36
No, I deactivated after I got the RSA key working with root, I thought it would just work with any other use too. – Archey Jan 8 '13 at 19:05
Well, you need a key in the authorized keys file for every user afaik. I think you have locked yourself from your server and need to contact support (although I might be wrong). – Baarn Jan 8 '13 at 19:09
I'm not worried about locking myself out. How does the authorized_keys file determine which public key is for which user? – Archey Jan 8 '13 at 19:12
the user is determined by how you log in eg ssh user@host, the server then checks the users .ssh folder on the server for the authorized_keys file. I am guessing, but afterwards it maybe checks the /etc/ssh/.ssh/authorized_keys file (path might differ) for a fitting key. If you stored your root-pubkey in that file you should still be able to log in with another user, if you use the same private key. – Baarn Jan 8 '13 at 19:16

You'll want to do a bit of set-up first on the server.

1) Generate your key (looks like you are good there)

ssh-keygen -t rsa -b 1024 -C "Comment if you want it" -f id_arbitraty_name

2) Cat the Public (*.pub) key to the authorized_keys folder for the users you want to login as (As @John mentioned, 644 for these).

cat >> /home/<username>/.ssh/authorized_keys{,2}

(The expansion will do it to both authorized_keys and authorized_keys2)

3) Download the private key

scp user@server:/loc/on/server/id_arbitrary_name ~/.ssh/

4) Set safe permissions for the private key 600, since it's on your local machine

chmod 600 ~/.ssh/id_arbitrary_name


5) If you want to save typing locally, set-up a local config file in ~/.ssh/

vim ~/.ssh/config

Host SomeIdentifyingName
    User username
    IdentityFile ~/.ssh/id_arbitrary_name

That allows you to just type ssh SomeIdentifyingName (tab completion works on that!) and connect.

Note Looks like you disabled root login, so this doesn't really apply to you. However, for future readers:

All the above being said, segregation of Keys is suggested. Otherwise, if I don't specify a username and the server prompts - root is an obvious one to try!

share|improve this answer

I think even it takes too long time but it is better to post my own experiment, I was trying to make non-root user to run an ssh session to a server , and failed even i set up properly all the configurations.

Finally i repeat the configuration but from the CLI terminal this time , and now it is fine every thing going OK.

Every one who had this problem can check here are the steps

share|improve this answer
could you please include all the information in your post please? that way the information will not be lost to Link Rot. thank you – Malachi May 3 '14 at 2:49

You should be able to put the public key in ~/.ssh/authorized_keys or ~/.ssh/authorized_keys2 (mode 600) and have it work just like it does with the root account.

Execute these commands to correct permissions

$ chmod 600 ~/.ssh/authorized_keys2
$ chmod 600 ~/.ssh/authorized_keys
$ chmod 700 ~/.ssh
share|improve this answer

You must log in to answer this question.

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