I tried the following command using my Mac Terminal

scp -rp /path/file user@SERVER_IP:/path/destination/folder

It gives me following error:

user@SERVER_IP: Permission denied (public key).
lost connection

Is there any ports that i am missing to open?

  • 1
    Hello, are you able to connect to the server over ssh? – pa4080 Mar 12 at 7:51
  • I am using GC Compute Engine. I am able to connect using SSH button on VM Instance on GC – Maqsud Inamdar Mar 12 at 7:57
  • 2
    "Is there any ports that i am missing to open?" no you are missing a public key. Please read up on how security works in regards to scp. – Rinzwind Mar 12 at 8:31
  • See for instance askubuntu.com/questions/803908/… But be careful. Doing it incorrectly can lock you out. – Rinzwind Mar 12 at 8:33
  • 1
    Does this answer your question? Filezilla or WinSCP alternative for Ubuntu – pa4080 Mar 12 at 13:50

Normally, scp asks for a password. To avoid this, or to automate file copying in scripts, public key authentication is usually used. The basic idea is to create a key pair on the client and copy the public key to the server into an authorized keys file.

Sources: https://www.ssh.com/ssh/scp#configuring-public-key-authentication

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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