EN
Bash - run command on server over SSH and automatically enter password
6 points
In this short article, we would like to show how to run command on server over SSH and automatically enter password in Bash.
By default ssh
command doesn't let to insert a password as a parameter, the solution is to use sshpass
or plink
command.
Quick solution:
xxxxxxxxxx
1
plink -pw user_password user@$my-domain.com "command_to_run -arg1 -arg2 -argN"
Note:
plink
is available under Windows and Linux - check the installation section.
xxxxxxxxxx
1
plink -pw my_secret_password john@$my-domain.com "cd / && ls -al"
Under Windows, you can use putty installer (go to MSI (‘Windows Installer’) section).
Under Debian based Linux run:
xxxxxxxxxx
1
sudo apt-get update
2
sudo apt-get install plink