3

I know I could get a list of hostnames into bash tab-completion of ssh by adding them to /etc/hosts, but since they are on DHCP, it's kinda bad practice.

Does anyone know another DHCP-aware way, that doesn't force me to interfere with Ubuntu too much?

(Global solution preferred)

arney
  • 153
  • 8
  • what OS is running your DHCP server? What DHCP server is being used? Do you puppet or any configuration management system? See - http://serverfault.com/questions/416779/smoothest-workflow-to-handle-ssh-host-verification-errors/416782#416782 – Zoredache Apr 25 '13 at 22:59
  • I just have clients. DHCP is managed by hoster. Puppet is too much overhead for my purposes. – arney Apr 26 '13 at 09:23

2 Answers2

3

The simplest way is to simply disable the HashKnownHosts option globally or in your personal .ssh/config file. If you disable that, and also have the bash-completion package installed, then any host you connect to will be available for auto-completion after you have connected the first time.

You could use ssh-keyscan to build up a nice big list to pre-populate your known_hosts file.

Zoredache
  • 130,897
  • 41
  • 276
  • 420
  • My `known_hosts` file is `/dev/null` as Keys change frequently :-( – arney Apr 25 '13 at 22:36
  • For auto-completion to be possible there has to be some source of data on your system that bash can use as a source. If you aren't defining your hosts anywhere on the local system you are probably out of luck. – Zoredache Apr 25 '13 at 22:57
  • Sure, but host id checking is just too damn naggy. Apart from that, I'd have to copy that file into every other users directory, overriding their's :-( – arney Apr 26 '13 at 09:21
1

Came up with a good one myself:

sudo sh -c "echo 'Host client1.hoster.org' >> /etc/ssh/ssh_config"

works immediately and for every user :-)

arney
  • 153
  • 8