使用expect和ssh遠端執行命令的指令碼

2021-06-06 06:58:10 字數 453 閱讀 2642

#!/usr/bin/expect -f

exp_version -exit 5.0

if

set cmd [lindex $argv 0]

set password [lindex $argv 1]

eval spawn $cmd

set timeout 30

while -re "enter passphrase for key " -re "password:" -re "permission denied, please try again." -re "kb/s|mb/s" -re "file list ..." -re "bind: address already in use" -re "is a directory|no such file or directory" -re "connection refused" timeout eof

expect使用ssh登入指令碼

基礎篇 u s ssh spawn ssh l root 10.10.10.24 等待響應,第一次登入往往會提示是否永久儲存 rsa 到本機的 know hosts 列表中 等到回答後,在提示輸出密碼 之後就直接提示輸入密碼 expect yes no password host interact ...

遠端連線和SSH

ifconfig 和 ip addr 檢視ip資訊。ifconfig為net tools中的命令,ip addr為iproute2中的命令 配置ssh服務 1 安裝openssh 1 1 客戶端 openssh client sudo yum install openssh clients 1 2 ...

Mac 使用SSH遠端登入

mac terminal是自帶ssh的,可以用whereis來看看 whereis ssh但是在現有程序中找不到ssh對應的程序 ps aux grep ssh 0.00.0 2432784 616 s000 r 3 14下午 0 00.00 grep ssh ssh connect to host...