Automate SSH using expect script
06 Feb 2023
This file contains 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 -f | |
set pass "password" | |
set server "hostname" | |
set user "username" | |
set port "27308" | |
set timeout 2 | |
spawn ssh $user@$server -p $port | |
expect "RSA key fingerprint" { send "yes\r" } | |
expect "?assword:*" { send "$pass\r" } | |
send -- "\r" | |
interact |