I need to pass a password to my ssh connection from Windows. I cannot use things like Putty or just use a key file.
ssh user@ip -p "password"
Is it possible to do this without an external module, perhaps by pressing the keys programmatically?
CodePudding user response:
You need to activate the ssh optional feature in windows.
Go to Settings > Apps and click “Manage optional features” under Apps & features. A list of optional features will be displayed.
Just click on install over the “OpenSSH Client (Beta)” element.
After installation, you will be able to shh with cmd or powershell console, i.e., no external programs like putty will be required.
Source: https://www.howtogeek.com/336775/how-to-enable-and-use-windows-10s-built-in-ssh-commands/
CodePudding user response:
If you need to connect to a server programmatically, you must use a public-private key pair.
Run the following on your windows machine:
ssh-keygen
Hit enter to use default path and leave the passprase blank. Two files will be generated: id_rsa (private key) and id_rsa.pub (public key).
Copy the public key to the server.
scp .ssh/id_rsa.pub user@ip:
Then log into the server and add the public key to ssh authorization file.
cat id_rsa.pub >> .ssh/authorized_keys
And that's all. Now you should be able to log into the server from your windows machine without entering any password.