Howto use secure shell in a script without having to type in the passphrase.
It is not too complicated. Just add the following in you script (well similar):
This program has to echo out the password, so hide it in your .ssh directory. That is a secure place.
suggested filename: $HOME/.ssh/.passwd_type
chmod 700 $HOME/.ssh/.passwd_type
type could stand for rsa, dsa, ssh or whatever you like if you need to identify different passphrases.
The final bit would look like this:
#!/bin/bash
SSH_ASKPASS="${HOME}/.ssh/.passwd_type"
DISPLAY=localhost:0
export DISPLAY SSH_ASKPASS
eval `ssh-agent 1>/dev/null`
ssh-add $HOME/.ssh/.id_type 2>/dev/null
# And now your SSH/SFTP commands should work here straight through. ie.:
ssh @uname -a
---end snipplet---
now you run your program:
program
and it will return:
SunOS 5.10 Generic_118833-36 sun4u sparc SUNW,Ultra-5_10 Solaris
enjoy.
Addi
Thursday, 22 February 2007
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment