You are not logged in.

#1 2017-10-22 12:36:55

7thSon
Member
Registered: 2017-05-07
Posts: 186

[SOLVED] Multiple SSH keys to one target user

I'm working on setting up a borg backup to my NAS, and am having a small issue.
I set up an SSH key (RSA) for my standard user "user" on my desktop, I put that key on the server in /var/services/homes/borg/.ssh/authorized_keys and that works perfectly.
The problem however is that I'm running my borg script on my desktop as root (sudo sh borg.sh), so the key on the server doesn't work since its not for the root@arch user. This results in a password prompt to connect via SSH to borg@server, which will not work for automated backups.

So I tried finding a solution and it was suggested in some forum posts that one should just append another key to the first file, so that both user@arch and root@arch keys are in the same file /var/services/homes/borg/.ssh/authorized_keys
This however doesn't seem to work. Is this an incorrect way of fixing the problem?

In short I need both user@arch and root@arch to be able to SSH into borg@server with paired keys and no password prompts.

Last edited by 7thSon (2017-10-22 20:44:44)

Offline

#2 2017-10-22 12:40:49

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,597
Website

Re: [SOLVED] Multiple SSH keys to one target user

Can you use ~/.ssh/config

Host foo
IdentityFile ~/.ssh/key1

Host bar
IdentityFile ~/.ssh/key2

CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#3 2017-10-22 15:13:57

nesk
Member
Registered: 2011-03-31
Posts: 181

Re: [SOLVED] Multiple SSH keys to one target user

Did you try creating a key for root and adding it to authorized_keys on the server as well?

Offline

#4 2017-10-22 20:24:44

7thSon
Member
Registered: 2017-05-07
Posts: 186

Re: [SOLVED] Multiple SSH keys to one target user

graysky wrote:

Can you use ~/.ssh/config

Host foo
IdentityFile ~/.ssh/key1

Host bar
IdentityFile ~/.ssh/key2

I put the 2 lines with "IdentityFiles" in my config before, but that doesn't seem to work, what should I put on the Host line instead of "foo" and "bar", is it the usernames on my desktop?

Offline

#5 2017-10-22 20:42:28

7thSon
Member
Registered: 2017-05-07
Posts: 186

Re: [SOLVED] Multiple SSH keys to one target user

I got it working now, the trick was to have both keys on separate lines in the authorized_keys file on the server, if they're on the same line it seems like it might break.
Thanks for the suggestions!

Offline

Board footer

Powered by FluxBB