linux expect
expect -c " set timeout -1; spawn ssh root@192.168.6.132; expect { *(yes/no)* {send yes\r ;exp_continue;} *password* {send 123456\r ;exp_continue;} eof {exit 0 } }"; 透過expect工具,shell在while迴圈中完成服務期間的免密登入一鍵話指令碼 1.前提要安裝expect包 2.程式碼如下: #!/bin/sh #主伺服器密碼 password=123456 while read hostname ; do expect -c " set timeout -1; spawn ssh-copy-id ${hostname} ; expect { "*password:*" {send -- ${password}\r ;exp_continue;} "*\(yes/no\)*" {send -- yes\r ;exp_continue;} eof {exit 0;} }" echo "hosts:${hostname} done." #ipconf.cfg 中存放要與主伺服器要免密登入的使用者的ip 例如: root@1921.68.245.134 每一行的格式與該例相同 done < ipconf.cfg ifconf.cfg示例: root@192.168.6.132 root@192.168.6.133
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31506529/viewspace-2199363/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- linux expect 的基本使用Linux
- Linux下expect安裝Linux
- LINUX EXPECT的安裝Linux
- linux expect 簡單講解Linux
- linux expect自動登入ssh,ftpLinuxFTP
- linux expect詳解(ssh自動登入)Linux
- expect安裝
- Linux使用expect實現遠端拷貝檔案Linux
- 使用Linux expect批次巡檢Linux Aix Solaris磁碟使用率指令碼LinuxAI指令碼
- 【expect】用expect實現scp/ssh-copy-id的非互動
- expect安裝及使用
- CentOS下expect 安裝CentOS
- expect批量修改密碼密碼
- linux下expect環境安裝以及簡單指令碼測試Linux指令碼
- Linux系統中expect該如何使用?有哪些常用命令?Linux
- 自動化運維 Expect運維
- Linux/Unix shell內嵌expect自動配置多臺主機SSH互信Linux
- 轉載:__builtin_expect 說明UI
- ruby_expect模組的使用..薦
- React v16.7 “Hooks” – What to ExpectReactHook
- 使用expect執行動態指令碼指令碼
- 使用expect指令碼SCP拷貝檔案指令碼
- 客戶端自動配置安裝(expect工具)客戶端
- expect ':' at 0, actual = (JSON轉化異常解決)JSON
- 定義/賦值陣列、 expect預期互動賦值陣列
- CentOS使用expect批次遠端執行指令碼和命令CentOS指令碼
- 小花狸監控之安全加固expect備份指令碼指令碼
- What to Expect When Moving From SAP Business Suite to SAP S/4 HANAUI
- expect+scp傳輸檔案發現檔案丟失
- 通過expect實現ssh協議自動輸密碼協議密碼
- Elements in iteration expect to have ‘v-bind:key‘ directives.eslint-plugin-vueEsLintPluginVue
- Jest 測試框架 expect 和 匹配器 matcher 的設計原理解析框架
- scp後臺靜默執行(使用expect自動輸入密碼)密碼
- mocha 的基本介紹&&expect風格斷言庫的基本語法
- UVA 11427 Expect the Expected (概率dp+推公式求期望 詳解)公式
- [問題]使用operator.eq(expect,res1)後改變了引數型別型別
- curl沒有接收到返回資料?curl響應頭EXPECT:100-continue
- Springboot中配置動態sql查詢出現的錯誤syntax error, expect ‘)‘Spring BootSQLError