開發使用linux烏班圖的系統,沒有類似SecureCRT的工具,每次登陸linux系統都需要輸入密碼,
很浪費時間。於是弄了一個腳本讓他們每次都直接輸入一個服務器別名就能登陸linux系統。以下
是具體操作步驟:
1.vim /root/expect_ssh.exp #!/usr/bin/expect -f set timeout 99 set host [lindex $argv 0] set port [lindex $argv 1] set username [lindex $argv 2] set password [lindex $argv 3] spawn ssh -p $port $username@$host expect { "yes" {send "yes\r";exp_continue} "*assword" {send "$password\r"} } expect "from" interact 2.別名設置vim .bashrc alias server1='expect -f /root/expect_ssh.exp 1.1.1.1 22 root "123456"' 3.刷新 .bashrc 環境變量 source /root/.bashrc 4.在linux系統使用server1別名登陸系統,到此1.1.1.1 服務器就能實現在烏班圖系統的自動登陸了。