Glam Prestige Journal

Bright entertainment trends with youth appeal.

I can login to the remote server via ssh and navigate through it's file system, but as soon as I try to scp a file from the server to my laptop I get an error message.

Example:

user@server:/file$ scp -r user@server: /file/ /My/Home/Dir [I Hit Enter]
Permission denied (publickey)

Why am I getting this error, and how can I resolve this.
Thanks

6

3 Answers

Your server doesn't have a private key to access to your laptop. The relationship is only one-way.

You'll need to create a key on your server and add its public key to your laptop. Here's a basic outline:

  1. SSH in to your server
  2. run ssh-keygen to generate a key
  3. copy the generated public key to your laptop.
  4. You should now be able to SSH back in to your laptop.
1

Rather than using SCP to push a file from the server, to your laptop. Why not try using SCP on your laptop to pull a file from the server? This would mean you wouldn't need to setup an an SSH server on your laptop, or configure public key authentication for your server. The SCP command you initially posted intends to do this. You simply ran it from the wrong place.

Rather than executing this command from within your SSH session on the server, run it from a terminal window on your laptop.

I had the same trouble. My fault was, that I forgot to add my private key to the ssh-agent after I reformatted my partition. If you have the same issue, fix it by:

$ ssh-add /path_to_your_private_key

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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