-1

Apologies if this has already been asked already, but I tried a quick search and couldn't find my problem.

Basically I am trying to SSH a file onto my friends server from my computer for him to read and modify himself. He has given me my own login and sufficent rights etc, but he is unable to see what I've uploaded to the server, nor can I see what he has added.

I am currently using: scp hello.txt username@domain.com:/home/username/ which uploads correctly and I can see it.

Could someone please help me out and explain why he is unable to view what he's uploaded, and vice versa? How can we set it up so we can see each others files and modify them (some sort of public folder?)?

Cyclonecode
  • 29,115
  • 11
  • 72
  • 93

1 Answers1

1

The problem are most likely the access rights on the directory/file. A non-root user might not be able to see the contents of the home directory of another user. If you upload a file to your home directory, your friend can consequently not see the uploaded file and vice versa.

The solution is simple: you need a directory on which both of you have the appropriate permissions, as you already assumed. Try this:

# on the server
mkdir /var/your_share/
chmod o+rwx /var/your_share/

# on your host
scp hello.txt username@domain.com:/var/your_share/

# on the server
ls -l /var/your_share/hello.txt

The ls -l displays the permissions of the uploaded file.

-rw-r--r-- 1 username username 10 Oct 13 15:49 hello.txt

If it says something like this, your friend will not have permissions to change the file but only to read it. Use the following command to grant him write permissions for that file:

# on the server
chmod o+w /var/your_share/hello.txt
ls -l /var/your_share/hello.txt

The output should then be something like:

-rw-r--rw- 1 username username 10 Oct 13 15:49 hello.txt

Note: The permissions granted in these commands are not only for the account of your friend but for all accounts on the server. That means everybody can read and write to the file. If you want to change that, you have to setup a group and only grant rights to the group.

Tim Zimmermann
  • 6,132
  • 3
  • 30
  • 36
  • Thank you for your speedy reply. When i try to: "mkdir /var/your_share/" it says "mkdir: cannot create directory '/var/your_share': Permission Denied". I am able to cd /var/ and view the files in there. So I guess he hasn't given me sufficient rights to do so? – craigwilkinson94 Oct 14 '14 at 06:17