Create AutomateLoginSSH.sh

Expect command examples
This commit is contained in:
Ankam Ravi Kumar
2021-08-05 21:47:24 +05:30
committed by GitHub
parent b4552a96d0
commit a4c4cd8b8a

20
AutomateLoginSSH.sh Normal file
View File

@ -0,0 +1,20 @@
#!/usr/bin/expect -f
## Testing expect command
## echo the test
puts "\nGet HostName\n"
## execute ssh command to connect to remote host
spawn ssh 192.168.175.130 "hostname"
## Look for password string
expect "password:"
## Send the password
send "redhat\r"
puts "\nGet df command output\n"
spawn ssh 192.168.175.130 "df -h"
expect "password:"
send "redhat\r"
interact