There is no clean solution for the problem you noted as far as I am aware.
The previously suggested /dev/null redirection will still display the warning, it just disables the security feature of storing the remote keys by redirecting the output into /dev/null.
So ssh would still think it writes something which is actually discarded.
As I know the only option is to catch the message and remove it from stdout.
ssh/scp..... 2>&1 | grep -v "^Warning: Permanently added"
Here is a complete example that you can use as wrapper to hide such warnings:
#!/bin/bash
remove="^Warning: Permanently added" # message to remove from output
cmd=${0##*/}
case $cmd in
ssh)
binary=/usr/bin/ssh
;;
*)
echo "unsupported binary ($0)"
exit
;;
esac
$binary "$@" 2>&1 | grep -v "$remove"
To install it all you need to do is add/modify the "case" statement for the actual command you wish to modify. (ssh, scp, git etc).
the "ssh)" means the script has to be named "ssh" (or a link to the script is named ssh).
The binary=/full/path is the path to the binary the script should wrap.
Then put the script with a name of your choice into /bin or somewhere else.
The script also the place where you can use a -o "UserKnownHostsFile=/dev/null" to the $binary variable, that's a lot better than putting such a security risk into the global ssh configuration which will affect all your ssh sessions and not just those you want to supress the message.
Disadvantages:
It's a bit overhead, not a perfectly clean solution and moves stderr into stdout which might not be good in all cases.
But it will get rid of any sort of warning messages you don't wish to see and you can use a single script to wrap all binaries you want (by using filesystem links to it)
The authenticity of host '...' can't be established. RSA key fingerprint is .... Are you sure you want to continue connecting (yes/no)?
, or have you suppressed that? If it is, is it the same fingerprint every time? If it's not, that's really scary. The less scary option would be that somehow it's not actually managing to write to the hosts file, so it tries again every time. Have a look at~/.ssh/known_hosts
? – Cascabel~/.ssh/known_hosts
? (Is it listed 5000 times?) Does~/.ssh/config
exist/contain anything (especially a value forStrictHostKeyChecking
)? – Cascabelknown_hosts
file are bad. It should be the host key, on one terribly long line. If you only have the host name there (for example) it will not work. I recommend that you remove this file (if indeed it only contains the information for this single host) and allow SSH to create it next time you connect. It should be silent after that. – tripleee