使用expect 作了一个ssh隧道自动登录:
#!/usr/bin/expect
set timeout 30
spawn ssh -Nf -R 2022:127.0.0.1:22 77.33.1.177 -o TCPKeepAlive=yes
expect "password:"
send "123456\r"
interact
运行没有问题,然而并没有执行(没有这个进程).
但是,在命令行下直接输入
ssh -Nf -R 2022:127.0.0.1:22 77.33.1.177 -o TCPKeepAlive=yes
再输入怕ssword
却没有问题?
why?