有些时候我们想实现自动登录,但又没法使用公钥验证,这时候 expect 就派上用场了。
一行版本:
1 |
expect -c "spawn ssh [email protected]; expect \"password\"; send \"your-password-here\r\"; interact" |
Script 版本:
1 2 3 4 5 6 |
#!/usr/bin/expect spawn ssh username@server.domain expect "password" send "your-password-here\r" interact |