I want to connect to a host via SSH but I don't want the hostname to be added to my
How can I do that?
Stack Exchange network consists of 181 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.Visit Stack Exchange
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
grep -v "^Warning: Permanently added"May 18, 2011 at 17:34
grepwill merge stdout and stderr; also the exit status can change. If using
bash, it will be better to use process substitution to get rid of the message:
ssh 2> >( egrep >&2 -v '^Warning: Permanently added') -o "UserKnownHostsFile /dev/null" [...]. It will avoid the pipe and thus the corresponding changes in exit status handling.
If you want this behavior because you're working with cloud servers (AWS EC2, Rackspace CloudServers etc.) or you're constantly provisioning new images in Vagrant you may want to update your SSH config instead of adding bash aliases or more options on the command line.
Consider adding something like:
Host *.mydomain.com StrictHostKeyChecking no UserKnownHostsFile /dev/null User foo LogLevel QUIET
For a single ssh session, use this
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null user@host
I feel like adding the host key to your known_hosts (the folks running these services are, in my experience, at least smart enough to keep their host keys consistent between machines serving the same hostname) and then turning on StrictHostKeyChecking, turning off CheckHostIP, and logging with LogLevel ERROR will give you the best experience without sacrificing security. (Ok, without CheckHostIP you do need to trust DNS, which is a huge gaping hole without widespread DNSSEC or something similar; but we'll just sweep that under the rug for the moment.)
I use a read-only known_hosts file, so I have to do something or I get endless warnings about not being able to add entries to known_hosts.
What I use:
Host github.com *.github.com StrictHostKeyChecking yes CheckHostIP no LogLevel ERROR
I would like these services to publish their SSH host keys on their websites via HTTPS, so I can copy them explicitly without having to connect first and potentially expose myself to a MITM attack.
so you still get "Could not resolve hostname" and other such errors
Have you tried disabling
StrictHostKeyChecking? You can do it with the
-o option or in the configuration file
I found the following .ssh/config entries useful (LAN with DHCP and DNS):
CheckHostIP no Host *.* CheckHostIP yes
Result is local machine names "zora" or "goron" will not check against dynamically assigned IP addresses, but www.mycompany.com or node42.planetlab.com will still have their static IPs confirmed.