I was looking for a quick and dirty way to SSH into a handful of hosts. I SSH into these hosts all day long, and I was looking for a way to skip the password prompt (I’m way too much into efficiency — every second counts!). I wasn’t interested in learning how to set up the public/private key authentication. I just wanted to automate the login so all I would need to type is goto host. Obviously this is less than secure, but I’m not overly concerned with security at my workstation.
Here’s what I came up with:
1) a file named goto.passwd
– which contains hostnames, usernames, and passwords (e.g. myhost myuser mypassword)
2) a script named goto
– which accepts one parameter (e.g. goto myhost)
– parses the goto.passwd file looking for that host
– and then passes that info to
3) a script borrowed from here
– and slightly modified.
Here is an example (the command is simply goto myhost and I’m instantly in.):
spawn ssh user@myhost
user@myhost’s password:
Last login: Tue May 18 11:31:05 2010 from 1.2.3.4
-bash-3.2$
Here are the scripts (you can also download them as a zip or tar):
goto.passwd
myhost root password myotherhost root passwordforroot anotherhost root password12345
goto
#!/bin/bash
host=$1
user=`cat goto.passwd | grep -e ^$host | awk '{print $2}'`
pass=`cat goto.passwd | grep -e ^$host | awk '{print $3}'`
goto.expect $user $pass $host
goto.expect
omitted. see zip or tar file below.
