• 1 
瀏覽模式: 普通 | 列表

ssh 搭配 expect 讓登入時可以自動化

一般我們使用 ssh 登入 linux 不外乎要輸入密碼,不用密碼的話就是 public key 了,
但如果不用以上兩種方式的話,就利用 expect 作互動方式,
有個參考範例如下
Quote: http://bash.cyberciti.biz/security/sshlogin.exp.php
#!/usr/bin/expect -f
# Expect script to supply root/admin password for remote ssh server
# and execute command.
# This script needs three argument to(s) connect to remote server:
# password = Password of remote UNIX server, for root user.
# ipaddr = IP Addreess of remote UNIX server, no hostname
# scriptname = Path to remote script which will execute on remote server
# For example:
#  ./sshlogin.exp password 192.168.1.11 who
# ------------------------------------------------------------------------
# Copyright (c) 2004 nixCraft project <http://cyberciti.biz/fb/>
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)

[閱讀全文]

標籤: ssh expect 自動化

  • 1