ExpectコマンドはLinuxのプロキシチェーンでは機能しません。

ExpectコマンドはLinuxのプロキシチェーンでは機能しません。

私はExpectコマンドを使用してパスワードを提供する小さなスクリプトを書いています。目的は、スイッチにログインしてコマンドを受信することです。オペレーティングシステム:RHEL 7.クライアントネットワークにログインするための小さなアプリケーションプロキシチェーンがあります。したがって、まずそれを開き、コマンド(sshなど)を実行する必要があります。

たとえば、

[ram@abcde scripts]$ /usr/bin/proxychains ssh [email protected]
ProxyChains-3.1 (http://proxychains.sf.net)
|S-chain|-<>-129.39.159.150:1080-<>-138.222.124.15:1080-<><>-10.49.99.49:22-<><>-OK
[email protected]'s password: 

Expectを使用して上記のタスクを自動化しようとしているので、次のスクリプトがありますが、エラーが発生します。

set user "admin"
set password "sample123"
/usr/bin/proxychains ssh [email protected]
expect "ssword: "
send "$password\r"
expect ">\r"
send "switchshow\r"
expect eof

次のエラーが発生します。

[ram@abcde scripts]$ sh br1.sh 
usage: ssh [-1246AaCfgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]
           [-D [bind_address:]port] [-E log_file] [-e escape_char]
           [-F configfile] [-I pkcs11] [-i identity_file]
           [-L [bind_address:]port:host:hostport] [-l login_name] [-m mac_spec]
           [-O ctl_cmd] [-o option] [-p port]
           [-Q cipher | cipher-auth | mac | kex | key]
           [-R [bind_address:]port:host:hostport] [-S ctl_path] [-W host:port]
           [-w local_tun[:remote_tun]] [user@]hostname [command]
br1.sh: line 3: ProxyChains-3.1: command not found
couldn't read file "ssword: ": no such file or directory
br1.sh: line 5: send: command not found
couldn't read file ">\r": no such file or directory
br1.sh: line 7: send: command not found
couldn't read file "eof": no such file or directory

ベストアンサー1

SSHでSSHPASSを使用してください。通事論:

sshpass -p 'password' ssh user@domain/ip "command"

おすすめ記事