Skip to content

Instantly share code, notes, and snippets.

@juner417
Created January 29, 2024 15:10
Show Gist options
  • Select an option

  • Save juner417/5e254ce4a4c4b297905da7c01edf8dd6 to your computer and use it in GitHub Desktop.

Select an option

Save juner417/5e254ce4a4c4b297905da7c01edf8dd6 to your computer and use it in GitHub Desktop.
handle a interactive ssh using expect script
#!/usr/bin/expect
set host "YOURGWHOST"
set username "YOURACCOUNT"
set password "[exec dec.sh]"
set timeout 30
spawn ssh $username@$host
expect {
"($username@$host) Password:" {
send "$password\r"
exp_continue
}
"Passcode or option (1-7):" {
send "1\r"
exp_continue
}
"Success. Logging you in..." {
interact
}
}
## dec.sh을 openssl을 기반으로 암호화/복호화 하는 별도의 스크립트
## 이건 각자 보안정책에 맞춰 사용하면 됨
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment