I've been silently learning from all of you for a long time. So thank you in advance for that! But now I got to a point where no google search can help with this issue I'm presented. I've found some info on these links, but sadly, it doesn't address exactly what I need (or at least I'm not seeing it):
[https://askubuntu.com/questions/30788/does-ssh-key-need-to-be-named-id-rsa][1]
[https://askubuntu.com/questions/888033/rsa-keys-not-authenticating][1]
Scenario: I have a Mac computer connected to a Ubuntu server through SSH.
I'm testing RSA key authentication through it, and it works right. However ONLY if the client key file name for the key is id_rsa.pub
. Whenever this name changes, the ssh handshake goes:
debug1: Next authentication method: publickey
debug1: Offering public key: rsa-key-2.pub RSA SHA256:********/s explicit
debug2: we sent a publickey packet, wait for reply
debug1: Server accepts key: rsa-key-2.pub RSA SHA256:*******/s explicit
Load key "rsa-key-2.pub": invalid format
debug2: we did not send a packet, disable method
debug1: Next authentication method: password
(rsa-key-2 is my second test key, I've .backup-ed the id_rsa original ones for testing purposes. As you can see, sshd seems to see the keys though, why doesn't it accept it?)
My issue is; what if I want to have more than one key to access different Linux machines? Can't I have a key1.pub, key2.pub, etc, file so I can store different keys on my computer for my different linux servers?
Workarounds attempted: I've been tinkering with sshd_config
(host end) and ssh_config
on the client end, but I didn't get to make it work (always restarting sshd after any changes).
PubkeyAuthentication
is set to yes.
I tried adding HostKey /etc/ssh/name of the key I want to use
but that didn't work either.
Do you think there's something I can do to have several local RSA keys that work with several different Linux machines (or the same, for testing purposes)?
I hope I explained my issue properly, and most importantly, thank you in advance for any input/help.
Regards!
-i identity_file
flag is to define the private rsa (id_rsa
) file to use. The .pub files should not be used directly beyond the initial setup with a given host. They are usually added to the host's~/.ssh/authorized_keys
file to enable a specific private rsa key's access. @iPodClassic Have you copied the contents of the relevantid_rsa.pub
file into the remote host's~/.ssh/authorized_keys
file?id_rsa.pub
? And why does it accept it when otherwise? <br/><br/> @SHawarden: Yes sir. authorized keys file shows both keys correctly .I´ve uploaded them víassh-copy-id
-i
switch, or create a~/.ssh/config
file with anIdentityFile
entry for the target host. Please show the SSH command plus any.ssh/config
that you are using on the Mac so that we can confirm that's what you are doing.~/.ssh/config
file? On my host machine there is no such file. I've read about that file, but wasn't really sure how to setupIdentifyFile
entry. Was it supposed to be on a root level? User level? So many questions! --- (Apologies in advance for my noobity, I guess we're all been there once, so thanks for your patience!)