實現:ssh遠程登錄,每次都要指定一堆用戶名和密碼,現要求實現自動登錄。
登錄流程:本地A 先登錄到 B 再由B 登錄到最終的C
如下:
代碼如下:
#!/usr/bin/expect -f
set timeout 30
spawn ssh B
expect "password:"
send "passwd@/r"
expect "]*"
send "ssh name@C -p port/r"
expect "password:"
send "passwd/r"
interact
要在系統上運行Expect必須首先安裝Tcl
#apt-get install expect
新聞熱點
疑難解答