[TriLUG] ssh command line
Kevin Hunter
hunteke at earlham.edu
Thu Aug 21 16:28:46 EDT 2008
At 3:59pm -0400 on Thu, 21 Aug 2008, Roy Vestal wrote:
> We're working with a script that we need to pass via the cmd line from
> one server to another (automation). We want to use ssh without using
> shared keys. Is there a way to pass the password to the command line?
I'm really curious why you don't want to use keys? I've yet to run
across a place where I haven't preferred keys. Depending on the setup,
they're more secure, and, after a cached password (or no password if
you're trusting), they're mucho faster. No password whatsoever and less
susceptible to man-in-the-middle attacks.
But, you know the specifics. I do not think ssh has a command line
option for this. Historically, the way around programs that don't let
you specify input non-interactively is to use expect:
Sample script:
#!/usr/bin/expect
spawn ssh localhost # start ssh
set password [lindex $argv 0] # set a variable
expect "password: " # look for this input
send "$password\r" # send this output. Note \r, not \n
expect eof # wait for ssh to complete
$ ./no_keys_ssh_script MyPasswordHere
Hope this helps,
Kevin
More information about the TriLUG
mailing list