I can use ssh command and provide password and connect to another server. But I need to pass password in the shell script. how?
Asked
Active
Viewed 605 times
0
-
Poor Mr. Torvalds. – Mingye Wang Oct 25 '15 at 07:46
1 Answers
2
For this you should use the sshpass application which should be available from your distribution's package manager.
Once installed you can set the ssh password to use from the command line, where uname -a is the command you want to run.
sshpass -p 'yourpassword' ssh youruser@yourhost 'uname -a'
p8952
- 660