LoginSignup
15
16

More than 5 years have passed since last update.

expectでsshのパスワード認証を自動化

Last updated at Posted at 2015-01-08
expect_ssh_password.sh
#! /bin/bash

host=xxx.xxx.xxx.xxx
login_name=hoge
password=xxxxxxxx

expect -c "
set timeout -1
spawn ssh -l $login_name $host
expect \"Are you sure you want to continue connecting (yes/no)?\" {
    send \"yes\n\"
    expect \"$login_name@$host's password:\"
    send \"$password\n\"
} \"$login_name@$host's password:\" {
    send \"$password\n\"
} \"Permission denied (publickey,gssapi-keyex,gssapi-with-mic).\" {
    exit
}
interact
"
15
16
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
16