Problems with multiple SSH keys

July 13, 2015 1.1k views
Security Linux Basics Ubuntu

Hello all,

I'm trying to get multiple SSH keys to work for different server users, but from the same local machine.

Here's the rundown of what I've done so far:

  • I have two user accounts on the server, one for system administration, and another one that I want to use for general website management through SFTP (does not have access to 'sudo' group).

  • I created SSH keys for both; added them to both my config file, and the authorized_keys file.

  • I can log in to my first, default account just fine, but connecting with the second one simply returns permission denied (publickey)

According to the debug output during connection, it finds the second key just fine, but for whatever reason refuses to use it. Shown below is what my local ssh_config file looks like.

Is there a step I'm missing or something I'm not doing right? Any help would be sincerely appreciated.

Thanks very much!

Host kcom-siteadmin
    User siteadmin
    HostName [my website]
    IdentityFile ~/.ssh/personal-web/siteadmin/id_rsa

Host kcom-sftp
    User sftpadmin
    HostName [my website]
    IdentityFile ~/.ssh/personal-web/sftpadmin/id_rsa
1 Answer

Figured it out: permissions for the authorized_keys file was borked for the second user. Rookie mistake.

Have another answer? Share your knowledge.