scp is returning a permissions denied, not sure why?

5,244

From the error shown above, it seems that you don't have enough permission to read the file:

scp:/some_file.gz: Permission denied

If you are confused whether the problem is network related or file system related, you can check it separately.

First, you can use ssh to make sure you can connect to the remote host.

$ ssh -p 30000 [email protected]

Second, you can use cp (as noted by Dennis Williamson) to make sure you can read the file.

You will get the "connection refused" error when you try to connect to a closed port on the remote host.

Share:
5,244

Related videos on Youtube

Blankman
Author by

Blankman

Updated on September 17, 2022

Comments

  • Blankman
    Blankman over 1 year
    scp -i ~/.ssh/my_id_rsa -P 30000 some_file.gz  [email protected]:/home/sshuser/ 
    

    And it returned:

    scp:/some_file.gz: Permission denied
    

    The rsa key file is the same file I use to connect via SSH (along with the port # and username and i.p)

    Does anything stand out that could be causing the permission issue?

    UPDATE

    I have iptables running, do I need another entry for scp or does it use ssh protocol? (silly question but just making sure here!)

    I'm not getting a 'connection refused' error so not sure if this is the issue.

    • Admin
      Admin over 13 years
      Do you have permission to read the file on your local system?
    • Admin
      Admin over 13 years
      yes I can read on my system no problem.
    • Admin
      Admin over 13 years
      Can you do cp some_file.gz /dev/null under the same conditions that the scp is failing?
    • Admin
      Admin over 13 years
      Can you run scp with --verbose option and post the result somewhere (e.g. on pastebin)?
    • Admin
      Admin over 13 years
      /some_file.gz in the error message of your scp call looks like you're trying to copy the file to the root directory (/) of the remote server. Is /home/sshuser/ filled in by a variable or do you literally provide that directory as a target?
    • Admin
      Admin over 13 years
      some_file.gz is in the current folder that I am executing this command, and yes I am literally typing in the /home/sshuser/