Home > Enterprise >  Is there a simple way to pass my password to the scp command?
Is there a simple way to pass my password to the scp command?

Time:12-28

I'm writing a program to send files to my server, but when I run the scp command, it asks for a password, I've looked at other answers but they all want me to download some 3rd party software that I don't want. Is there any way to pass my password to the scp command without other software?

I'm using Windows 10, and running the scp command in a batch file.

CodePudding user response:

It is generally not a good idea to include passwords in scripts, as it can be a security risk if the script is accessed by unauthorized parties. Instead of including the password in the script, you can use a ssh key pair to authenticate the connection.

To use a ssh key pair for authentication, you will need to generate a public/private key pair on your local machine and add the public key to the authorized_keys file on the remote server. You can then use the private key with the -i option in the scp command to authenticate the connection.

Here is an example of how you can use a ssh key pair with the scp command:

scp -i /path/to/private/key file.txt username@remote:/path/to/destination
  • Related