Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I currently have this in my .ssh/config file:

Host *
AskPassGUI no
IdentityFile ~/.ssh/%r@%h
IdentityFile ~/.ssh/%h
IdentityFile ~/.ssh/id_dsa

When I ssh into a host that I don't have a key file for, login works, but I also get these errors:

no such identity: /Users/user/.ssh/ No such file or directory
no such identity: /Users/user/.ssh/ No such file or directory

Ideally, i'd like ssh to check for the files, but not throw an error if any of them can't be found. The idea is to be able to put private keys named like "" or "" into my .ssh directory, and have ssh use those when logging in with that user / host combo, but not complain and then log in normally if the file is missing. I don't want to use Host directives as described in this answer, because I have a lot of key files and I'd rather not have to both add them to the folder, then edit the config file and add host directives for each one.

Is such a thing possible?

share|improve this question
Are those errors, or warnings? – Tom O'Connor Mar 18 '14 at 13:16
@TomO'Connor I suppose they are warnings since the login doesn't actually fail. – bmacs Mar 18 '14 at 22:19
up vote 4 down vote accepted

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.

share|improve this answer
You get a +1 for looking at the source – Jacob Apr 12 '14 at 5:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.