I'm getting this error when running ssh myhost2
:
no such identity: /home/myusername/.ssh/myhost2_rsa: No such file or directory
The details
On Ubuntu 16.04.4 LTS, I recently configured my SSH client to connect to multiple servers using different private keys.
My ~/.ssh/config
file has multiple host declarations, each with a different IdentityFile as below:
Host myhost1
HostName myhost1.com
user myhost1user
IdentityFile ~/.ssh/myhost1_rsa
Host myhost2
HostName myhost2.com
user myhost2user
IdentityFile ~/.ssh/myhost2_rsa
Host myhost3
HostName myhost3.com
Host myhost4
HostName xxx.xxx.xxx.xx
user myhost4user
IdentityFile ~/.ssh/myhost4_rsa
When I set these up a few days ago, all were working properly. In other words, I could use a command like this:
ssh myhost2
...and the SSH connection would work as expected.
Today, using the same command results in this error:
no such identity: /home/myusername/.ssh/myhost2_rsa: No such file or directory
Convinced that this was a file permissions problem, I have checked and rechecked that there are no group permissions on my home folder nor on my .ssh folder.
- My ~/.ssh folder has 700 permissions
- My /home/myusername folder has 700 permissions
And I've checked and rechecked the private key files:
- Each of my private key files (e.g.
myhost2_rsa
) has 600 permissions - Each of my private key files is owned by my user account (thanks for asking about this, @steeldriver). Here's the output of
namei -l /home/myusername/.ssh/myhost2_rsa
:
f: /home/myusername/.ssh/myhost2_rsa
drwxr-xr-x root root /
drwxr-xr-x root root home
drwx------ myusername myusername myusername
drwx------ myusername myusername .ssh
-rw------- myusername myusername myhost2_rsa
Since these were working a few days ago, I'm stupefied. This is still a recent Ubuntu setup for me, so I've been adding software and making configuration tweaks, but I can't think of anything that would have affected SSH or my home folder permissions.
Furthermore, I can still SSH into these same hosts from my Win7 machine via Putty using the same private keys.
Any ideas about what else I should be checking?
namei -l /home/myusername/.ssh/myhost2_rsa
namei -l /home/myusername/.ssh/myhost2_rsa