scp - Permission denied (publickey,gssapi-keyex,gssapi-with-mic)

Solution 1:

I was facing the same problem. Hope this will work for you.

scp -rp -i yourfile.pem ~/local_directory username@instance_url:directory

Permission should also be correct to make this work.

Solution 2:

Run scp with verbose mode (-vvv) and see if you can identify the problem there. It could be the permissions on your .ssh/authorized_key file on the destination (or even the source) are too open.

Solution 3:

Turns out I needed to specify the identity in the scp command something like so :

scp -rp -i /root/.ssh/server /home/user-data/* [email protected]:/home/user-data

where '/root/.ssh/server' is the location of the private key to be used. Permissions and ownership should be correct for it as well.