Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execute ssh with password authentication via windows command prompt

I need to execute ssh from windows command line by providing password in a non interactive manner. I could implement the key based authentication and able to execute the ssh commands just like

ssh <user>@<host> <command> 

Is there any commands like

ssh <user>@<host> -P <password> <command> 

enter image description here

I don't know if it is feasible. However, there can be some work around for the same. Throw me some ideas to accomplish the same.

like image 776
Balachandar Avatar asked Aug 25 '12 00:08

Balachandar


People also ask

How do I force SSH to password authentication?

To log in with a password, you'd have to start by reconfiguring the remote server to accept password authentication. Show activity on this post. Turns out the solution was to set PasswordAuthentication yes in /etc/ssh/sshd_config .

Can I SSH through CMD?

You can start an SSH session in your command prompt by executing ssh user@machine and you will be prompted to enter your password. You can create a Windows Terminal profile that does this on startup by adding the commandline setting to a profile in your settings.


1 Answers

The sshpass utility is meant for exactly this. First, install sshpass by typing this command:

sudo apt-get install sshpass 

Then prepend your ssh/scp command with

sshpass -p '<password>' <ssh/scp command> 

This program is easiest to install when using Linux.

User should consider using SSH's more secure public key authentication (with the ssh command) instead.

like image 136
Anish Bhatt Avatar answered Sep 28 '22 20:09

Anish Bhatt