SSH key Error:Server refused our key

Hello,

I've done the SSH key and it works well with the user root, but it doesn't work for other users. If I log in as another user, it always says"Server refused our key" and ask password. How to solve it? The key only works for root??

Thank you!

4 Replies

Have you added they key to the authorized_keys file for the user you're trying to log in with?

@obs:

Have you added they key to the authorized_keys file for the user you're trying to log in with?

Hi Obs,

Thanks for the explanation!

I've done the ssh key jobs for the user "root" and it works well. I'm not sure of these three things:

1, The ssh key pair only works for one user? Do I need to create another pair for other users I'd like to log in with? Like one ssh key pair=one user?

2, If one ssh key pair supports multiple users, how to add/delete users to share/not share this ssh key pair?

3, Or both 1&2 are right method to do with SSH key connection?

Thank you!

Each key pair can be used for any number of users on any number of servers, how you deal with it is up to you. A common practice is to have one ssh key per person and add that key to the servers/users they need access to.

If you want to have a key for both root and lets say the user bob then you copy that key into /root/.ssh/authorizedkeys and /home/bob/.ssh/authorizedkeys that's it :)

@obs:

Each key pair can be used for any number of users on any number of servers, how you deal with it is up to you. A common practice is to have one ssh key per person and add that key to the servers/users they need access to.

If you want to have a key for both root and lets say the user bob then you copy that key into /root/.ssh/authorizedkeys and /home/bob/.ssh/authorizedkeys that's it :)
Loud and clear! :D I've done the job. Thank you!

chown -R bob:bob .ssh

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct