Score:1

ssh not working when custom key name is used

sb flag

My SSH key(s) refuses to work on my new KDE neon install. I tried reinstalling the keys and finally found the problem in debug mode. The key file is not used because it has a custom name. This is surprising because it worked fine on Ubuntu 18.04 in the past years, but on the new KDE neon it has this bug.

The procedure is the usual (already worked on Ubuntu 18.04)

-generate key pair on admin side ssh-keygen -b 4096 (I assign a custom name to differentiate servers)

-add the new key to the server ssh-copy-id -i ~/.ssh/custom_name.pub [email protected]

Everything is fine, no errors, key is confirmed in ~/.ssh/authorized_keys on the server side

The problem seems to be that ssh does not try the custom name key when connecting:

debug1: Trying private key: /home/gerge/.ssh/id_rsa
debug1: Trying private key: /home/gerge/.ssh/id_ecdsa
debug1: Trying private key: /home/gerge/.ssh/id_ecdsa_sk
debug1: Trying private key: /home/gerge/.ssh/id_ed25519
debug1: Trying private key: /home/gerge/.ssh/id_ed25519_sk
debug1: Trying private key: /home/gerge/.ssh/id_xmss
debug1: Trying private key: /home/gerge/.ssh/id_dsa

If the key is called id_rsa then it works, but I need custom names because there are many keys. Any idea?

local admin system: KDE neon Linux HOSTNAME 5.15.0-56-generic #62-Ubuntu SMP Tue Nov 22 19:54:14 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Score:2
jp flag

This is not a bug.

You did not specify -i ~/.ssh/custom_name in your ssh(1) command, so it is using the defaults:

-i identity_file

Selects a file from which the identity (private key) for public key authentication is read. You can also specify a public key file to use the corresponding private key that is loaded in ssh-agent(1) when the private key file is not present locally. The default is ~/.ssh/id_rsa, ~/.ssh/id_ecdsa, ~/.ssh/id_ecdsa_sk, ~/.ssh/id_ed25519, ~/.ssh/id_ed25519_sk and ~/.ssh/id_dsa.

You could also add this to your .ssh/config, e.g.,

Host 192.168.x.x
  User user
  IdentityFile ~/.ssh/custom_name
Gerge avatar
sb flag
thanks, I did not know about `~/.ssh/config` file, but it is very nice and solved my issue
SayantanRC avatar
us flag
This does not answer the question completely. Why is the `-i` flag not required in Ubuntu or Ubuntu based distributions (like linux mint) but required everywhere else? What does Ubuntu do differently?
jp flag
@SayantanRC: What do you mean by that? It has a default value, and is required for paths other than the defaults regardless the distribution.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.