What if you want to use scripting Automation to log on to a machine and then execute a command on top of it?
Non-interactive commands that can be used with SSH
SSH [email protected] "/home/hczhang/bin/build.sh"
Here can use expect analog keyboard input password input, you can also use no password login, the specific is to put their own public key in the end of the Authorized_keys, login without losing password, is to establish the trust relationship between two machines, here not much to say.
So what if you want to execute the sudo command? Like what:
SSH [email protected] "sudo/home/hczhang/bin/build.sh"
Present a TTY to run sudo will appear,
We can simulate a TTY with the-t option.
ssh-t [email protected] "sudo/home/hczhang/bin/build.sh"
All right, here we go.
Original: http://blog.csdn.net/hongchangfirst/article/details/37922911
Author: Hongchangfirst
Hongchangfirst's homepage: http://blog.csdn.net/hongchangfirst
SSH performs noninteractive commands