Created
January 29, 2024 15:10
-
-
Save juner417/5e254ce4a4c4b297905da7c01edf8dd6 to your computer and use it in GitHub Desktop.
handle a interactive ssh using expect script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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