It is always the same: You are used to a technique like
(But this is not so secure like using ssh-keys!)
- accessing server via ssh with ssh-keys
- Poor man's approach
buffer the password and use the middle button on your mouse, each time the script asks for the password.
This works, but this is only "semi-automatic" - Use expect
With this tool it is very easy to automate logins without using ssh-keys. Just write a script auto.ssh.sh like this:
#!/usr/bin/expectThis script can be called with a parameter (here IP or hostname) and executes the date command on the server. Now just write a loop:
spawn ssh -l root $argv
expect "Password: "
send "mypassword\n"
expect "#";
send "date\n";
expect "#";
send "exit\n";
for server in 10.0.0.1 10.0.0.2 10.0.0.3; do ./auto.ssh.sh $server; doneAnd you are done...
(But this is not so secure like using ssh-keys!)
No comments:
Post a Comment