Problems with multiple SSH keys

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

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

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