SSH How do I ignore IdentityFile not found errors?
After reviewing openssh's source code, it seems that the answer is as follows:
OpenSSH considers the IdentityFile lines in ~/.ssh/config to be "user provided." If a user provided IdentityFile can't be found, it logs a warning to the console. See the 'load_identity_file' function in sshconnect2.c.
So unfortunately, it is impossible to do exactly what I want it to do, but a couple of workarounds exist:
One would be to add the line LogLevel ERROR
to your ~/.ssh/config file. This is one step below the default log level of INFO
. I didn't choose this as I wasn't sure what other warnings it would suppress.
The option I chose was to add the following lines to my /etc/ssh_config file:
Host *
IdentityFile ~/.ssh/%r@%h
IdentityFile ~/.ssh/%h
# The lines below maintain ssh's default behavior:
IdentityFile ~/.ssh/identity
IdentityFile ~/.ssh/id_rsa
IdentityFile ~/.ssh/id_dsa
I then removed the IdentityFile
lines from my ~/.ssh/config file.
Those lines are not considered "user provided" when they are in /etc/ssh_config, so nothing is logged when the file can't be found.