On 2022-04-09 at 17:14 -0700, Ayoub Misherghi wrote: > Hi, > Below I show two ways I ssh logged into a machine. > In the first method I referred to the remote machine > as 192.168.0.212 while in the second method I referred to the > remote machine as [1]testuser5@192.168.0.212 specifying the user. > In the first method it logged me in as user ayoub when the > .ssh directory of ayoub does not have the file for the key > specified with the -i parameter option. With the second method > it logged me in as the testuser5 user; as expected. > Some information about the bash version and the Linux version > is right at the bottom. > Thanks, > Ayoub
This is unrelated to bash, it's 100% ssh(1) behavior. Anyway, I bet one of the default keys *is* in the authorized_keys file for user ayoub. -i doesn't mean use this key _and only this_ The default key such as ~/.ssh/id_rsa, ~/.ssh/id_ecdsa, etc. are still tried, as well as others available in the ssh-agent. Run ssh with some -v to see what it is actually trying. Add -oIdentitiesOnly=yes to only use the identities explicitly provided. Regards