Ssh and scp key-free remote command execution: Keep CT, sshscp
First install CT
# Yum-y install benchmark CT
Command Format
#./Verify ct ip comm # verify CT is an independent tool, so sh cannot be used for execution.
| 12345678910111213141516171819 |
#!/usr/bin/expect set timeout -1 # The default timeout value is 10 seconds. If you want to execute a long command, it is necessary to set the timeout value to never time out. set COMMADN1 [lindex $argv 0] # Pass the parameter variable. The first parameter after the script is referenced here. set COMMADN2 [lindex $argv 1] # Pass the parameter variable. The second parameter following the script is referenced here. spawn ssh -p 22 $COMMADN1 $COMMADN2 # Ssh can be changed to an scp command for remote copying without a key expect { "yes/no" {send "yes\r";exp_continue} # Enter yes automatically when querying yes/no "password:" {send "123456\r"} # Automatically enter the defined password 123456 when querying the password } expect eof |