I want to ssh to remote machine within shell script but remote machine require password. How should i provide password in my script?
I tried below but its not working. Please suggest
#!/bin/bash
SSH <hostname>
<password>
I want to ssh to remote machine within shell script but remote machine require password. How should i provide password in my script?
I tried below but its not working. Please suggest
#!/bin/bash
SSH <hostname>
<password>
I suggest to use a ssk-key so you do not have to provide any password. There are plenty of tutorials out there on how to use them, for example this one.
In case you want to use inline password you can try installing sshpass
and executing:
sshpass -p 'YourPassword' ssh user@host
Source: SSH login with clear text password as a parameter?
By the way, if you want to execute a command in the remote machine, you just have to write the remote command between quotation marks:
sshpass -p 'YourPassword' ssh user@host "ls -l"