Search code examples
amazon-web-servicesamazon-ec2sshcommand-linescp

Can ssh and scp to ec2 linux instance but cannot scp from linux instance to local machine


I'm having a very strange issue. When I try to SSH into my linux instance using the following line, it works.

ssh -i "F:\Work\Thomas Final Site\Bhasha.pem" [email protected]

But when I try to scp from the linux instance to my home machine running Windows 7 using the following line, I get the following error.

scp -i "F:\Work\Thomas Final Site\Bhasha.pem" -r [email protected]:~/smart-two-site "F:\Work\smart-two"

Could not create directory '/home/User/.ssh'.
The authenticity of host 'xx.xxx.xxx.xxx (xx.xxx.xxx.xxx)' can't be established.
RSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx.
Are you sure you want to continue connecting (yes/no)? yes
Failed to add the host to the list of known hosts (/home/User/.ssh/known_hosts).
Permission denied (publickey).

I can't understand why using the same public key I would be able to ssh into the instance, but not scp from it. I can also scp from my local machine to the linux instance, but when I try to scp from my linux instance to my local machine from my local machine it crashes.

Any ideas as to what and why this is happening?


Solution

  • Use Filezilla in sftp protocol it should work. add ppk file to settings under sftp.