I have a public and private key in X:\secure. Straight ssh with the private key works and I connect okay:

ssh -i X:\secure\id_rsa remoteuser@remote.server.com

The remote server is all set up for ssh and has the public key from X:\secure\id_rsa.pub added to /etc/ssh/authorized_keys/remoteuser.

However, when I try to send a file over using

scp somefile.txt -i X:\secure\id_rsa remoteuser@remote.server.com:~

I get prompted for password.

Question: Is there a way to scp a file over seamlessly, without a prompt, just like ssh connection is established using a private key?

  • Are you prompted for the account password, or the SSH key passphrase?
    – user1686
    Oct 25, 2017 at 20:26
  • account password
    – amphibient
    Oct 25, 2017 at 20:39

3 Answers 3


I'm on a Winows 10 machine, connecting to a Ubuntu server. I've set it up so that I can only connect with a private key with a passphrase.

I'm using cmder and this works in Windows:

scp -i ~\.ssh\privatekey foobar.txt linuxuser@server:/home/linuxuser

~.ssh\ referes to C:\Users\.ssh\

  • I found PuTTY's openssh format works fine for the private key, although .ppk does not.
    – Wassadamo
    Feb 1 at 4:56

i am on linux so i can not test this but have you tried:

scp -i X:\secure\id_rsa somefile.txt remoteuser@remote.server.com:~

i'm pretty sure you have to put the options before the source file. if you're getting a password prompt then the key is not being sent.


Just giving my scenario as an answer here , any future readers may get benefited . File copied from Windows system to the Amazon EC2 instance running in Ubuntu.

C:\Users>scp -i "C:\aws\keys\JenkinsSrv.pem" jenkins-cli.jar ubuntu@ec2-18-222-189-18.us-east-2.compute.amazonaws.com:/home/ubuntu


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.