Connect to ssh and run command in 1 script
I login to ssh and run command manually and I want to script that.
For now I do :
ssh 192.168.1.5 -p 1234
and then I see [email protected]'s password:
then I press enter (empty password) and then I want to run shell command like ps
How can I do that all in 1 script?
Solution 1:
Running a command over SSH is easy. Just put the command at the and of the SSH command. For example, to run echo Hello
over SSH, with the user user
and the host host
, I could run this:
ssh user@host "echo Hello"
# and type the password (if there is one)