11

linux - Getting permission denied for SCP over SSH server to local - Stack Overf...

 2 years ago
source link: https://stackoverflow.com/questions/19777357/getting-permission-denied-for-scp-over-ssh-server-to-local
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Getting permission denied for SCP over SSH server to local

Asked 8 years, 5 months ago
Viewed 112k times
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

Want to improve this question? Update the question so it's on-topic for Stack Overflow.

Closed 4 years ago.

I'm trying to scp some files from a server to my local machine but I either get a permission denied, or the server is copying the files to the server

scp username@host:/files/to/copy/from/\* /path/of/local/destination/ --> permission denied

scp username@host:/files/to/copy/from/\* ~ -->server copies to home directory on the server

scp username@host:/files/to/copy/from/\* ~/Desktop -->server creates a file called Desktop on server

I'm not sure what to do, this is on a Mac btw

asked Nov 4, 2013 at 21:21

5 Answers

You need to use the -r for recursive copy and make sure you have write permissions to the destination. Try doing a touch /path/to/local/destination/file and see if you get permission denied. If so then use sudo scp to copy the files.

answered Nov 4, 2013 at 21:49

This can happen even if ssh works fine! The problem is File/Directory Permissions, for the most part! Using chmod 777 /path/dir/* gives write access to all the immediate children of /dir - including root files and directories. However, secondary files/directories are not affected by these permissions. Example: say i have this website: /var/www: index.php, css[mobile.css, global.css], js[init.js, fun.js], include[head.php, footer.php, body.php, fun.php]

To be able to overwrite fun.js: chmod 777 /var/www/js/*

answered Feb 7, 2015 at 8:32

I got the same issue. I use the username and password to scp files from windows to the username's account on ubuntu and get permision denied error. The reason is because one of the directory is owned by root. For example if the account is in /home/username then most likely /home is owned by root. If you change owner of /home then it may work. Try: sudo chown root: /folder

answered Nov 19, 2014 at 0:44

If there is a file with the same name as your source file in the destination directory, you need to remove it first. I encountered the issue like this.

answered Sep 14, 2017 at 2:56

I had the same problem.

Tried everything couldn't fix it, until I checked my ISP Gateway.

I work with a Zyxel gateway from my ISP and because that is far away from where I have another terminal I shoved a old Linksys DD-WRT flashed Router/Repeater in between. My host terminal that was connected to that Linksys was first connected to the Gateway with a DHCP table lock (I ordered the gateway to give the MAC from that terminal the same IP via DHCP). I did this because I first had a NAS server on that mac. Now I moved the terminal to another location and totally forgot the mac ip assignment.

So now i had a WIFI repeater connected to the Gateway, and the computer with the mac assigned was connected to that.

The problem now was that my Gateway thought it was the old NAS whilst it was the other terminal, and assigned the IP to the WIFI repeater, and this was an IP conflict so scp couldn't find the right location. Which on it's turn resulted in a access denied on scp. Weird was that everything did work out fine, i could get on the internet, surf, mail, but with scp it gave an conflict.

Changed it in the Gateway (removed the DHCP table), and assigned another ip to the terminal...

Now scp command worked as before!

It took me 8 hours to figure it out so I thought to share this little hickup that can really frustrate you freaking butt off...

Greets Pi @ir


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK