"sshpass is not recognized" on Windows

You cant run sshpass in windows. You can however use putty via the windows command line, to achieve the same thing.

putty -load "host" -l username -pw password

Also you can upload files via command line (with a password) using WinSCP

winscp /command "option batch abort" "option confirm off" "open sftp://user:[email protected]/" "put examplefile.txt /home/user/" "exit"

Instead of OpenSSH ssh, you can use PuTTY plink. It's command line equivalent of PuTTY and has very similar command-line syntax as OpenSSH ssh. But on top of it, it has -pw switch for providing a password.

The plink equivalent of your ssh call is:

plink ldap.nextstep4it.com -l root -pw password

You absolutely should not use -o StrictHostKeyChecking=no to blindly accept all host keys. That is a security flaw. You lose a protection against MITM attacks. Instead, with plink, you can use -hostkey switch to set the fingerprint of the expected host key.


Similarly:

  • instead of OpenSSH scp, use PuTTY pscp;
  • instead of OpenSSH sftp, use PuTTY psftp.

Both have the -pw switch.

Alternatively, both for SCP and SFTP, you can use my WinSCP SFTP/SCP client. WinSCP also supports providing the password on command-line/in script. And there's a guide for converting OpenSSH sftp script to WinSCP script.


No matter, if you use OpenSSH, PuTTY or WinSCP, it is always better is to use public key authentication than the password.