I want to copy some file to a remote Linux system from my Windows PC using pscp
(from putty). I wrote a small script that call the pscp commands in this way:
You can work this stuff out for yourself. Use the /?
option to see the help. The pertinent parts are included below.
>pscp /? PuTTY Secure Copy client Release 0.60 Usage: pscp [options] [user@]host:source target pscp [options] source [source...] [user@]host:target pscp [options] -ls [user@]host:filespec Options: ...... -l user connect with specified username -pw passw login with specified password ......
Use the -l
and -pw
options to specify a user and password.
So whilst that answers the specific question that you asked, the real opportunity for you is to learn how to obtain documentation from command line utilities.
pscp -pw yourPasswordHere C:\Users\testUser\Downloads\test.sh testUser@123.123.123.123:/home/testUser
I've noticed that no one posted sample of that command with -pw option.
sshpass -p'password' pscp -A -H "ip" -t 20 -l root /var/www/html/temp_santosh.txt /tmp/
You can use sshpass
with -p
option just before pscp
If your coping a local file to remote directory use:
pscp -pw yourPasswordHere C:\Users\testUser\Downloads\test.sh testUser@10.10.10.10:/home/testUser
If your coping a remote file to local directory use:
pscp -pr yourPasswordHere testUser@10.10.10.10:/home/testUser/test.sh C:\Users\testUser\Downloads\
Use putty to set up a remote login without a password. This will involve the puttygen command. You will need a private key and the target will need a public key. Once you verified that you have a good private key file and login without typing a password, you can reference it with the "-i" private key option on pscp. You might be able to set up the key without the putty connect if it isn't allowed, but this is the easiest way. Just say no to passwords in the clear:
C:\Users\riglerjo>pscp -i .ssh\rigler_rsa.ppk test.txt rigler@rigler.org:.
test.txt | 0 kB | 0.0 kB/s | ETA: 00:00:00 | 100%
From putty documentation
5.2.2.6 -pw passw login with specified password
If a password is required to connect to the host, PSCP will interactively prompt you for it. However, this may not always be appropriate. If you are running PSCP as part of some automated job, it will not be possible to enter a password by hand. The -pw option to PSCP lets you specify the password to use on the command line.