Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'SSH to multiple boxes via tab completion' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
SSH to multiple boxes via tab completion
Authored by: vdanen on Oct 14, '04 12:24:38PM
This kind of thing is what ~/.ssh/config is for. Very easy to use. For instance, to ssh into host1.somewhere.com as root you would add:

Host host1
  Hostname host1.somewhere.com
  User root
Then all you have to do is "ssh host1". Nice thing about this is you can set other options as well. For instance, I like to log into one of my webservers through a firewall that does port forwarding on a non-standard port to my webserver. I also need to ssh into the firewall box as well which is why I use a different port number, but I have it setup like this:

Host web
  Hostname 10.0.5.4
  Port 2022
  HostKeyAlias web
  CheckHostIP no
  ForwardX11 yes
  ForwardAgent no
  User vdanen
Now all I have to do is
ssh web
and I get logged in to port 2022 on the firewall host (10.0.5.4) which is forwarded to port 22 on the firewall. The HostKeyAlias and CheckHostIP clauses are necessary because otherwise ssh complains because I have the hostkey for 10.0.5.4 in ~/.ssh/known_hosts which is different from the host key for webserver ("web"). Use
man ssh_config
for more details, but I find using ~/.ssh/config for this kind of thing far more flexible than using bash aliases.

[ Reply to This | # ]