I can't transfer files using pscp to amazon AWS ec2 instances. Key refused

Theoden picture Theoden · Jan 7, 2016 · Viewed 7.7k times · Source

I can connect to the server command line using Putty using the same private key.

But when I try to use the same key to transfer a file from my PC over to the server":

pscp -i C:\xxx.ppk "C:\xx\somefile.yy" ec2-xx-xx-xxx-xxx.compute-1.amazonaws.com:/home/(some location)

I receive the following error:

Server refused our key Fatal: Disconnected: No supported authentication methods available (server sent: publickey)

Could someone help me with fixing this problem please?

Answer

Rodrigo M picture Rodrigo M · Jan 8, 2016

You may want to review the Error: Server refused our key or No supported authentication methods available section of the Troubleshooting Connecting to Your Instance document.

Try this: add the -l user name option to the pscp command line, with the proper username for your instance.

pscp -i C:\xxx.ppk -l user ec2-user "C:\xx\somefile.yy" ec2-xx-xx-xxx-xxx.compute-1.amazonaws.com:/home/(some location)

The -l option allows you to connect with specified username. You may have a username mismatch.