EN
Bash - run command on server from local computer (over SSH and automatically enter password)
6
points
In this short article, we would like to show how to run command on server from local computer 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:
plink -pw user_password user@$my-domain.com "command_to_run -arg1 -arg2 -argN"
Note:
plinkis available under Windows and Linux - check the installation section.
Practical example
plink -pw my_secret_password john@$my-domain.com "cd / && ls -al"
plink installation
Under Windows, you can use putty installer (go to MSI (‘Windows Installer’) section).
Under Debian based Linux run:
sudo apt-get update
sudo apt-get install plink