scp not allowing file transfer except to home directory [closed] - ssh

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I need to automate a file transfer using scp and I have created a new ssh key and sent the public key to the remote server where I'll be sending files to (# ~/.ssh).
The problem is that it won't allow me to scp the file anywhere except the home directory. If I transfer it to the home directory, it works fine, but not anywhere else.
Is there something that needs to be done here? Thanks!

If you can scp the file to your home directory, then your key is working. That is unlikely to be an issue.
The kinds of problems you might have would be:
You don't have permission to write to the destination directory
$ scp test.txt myserver:/root
scp /root/test.txt: Permission denied
In this case you need to get permission to write to the directory, or choose a different destination that you do have access to.
The destination directory doesn't exist
$ scp test.txt myserver:foo/bar/
scp foo/bar: No such file or directory
In this case, check that you're uploading to the correct path.
A destination like myserver:foo/bar/ (note: no / after the :) means a relative path to your home directory. So, it might be /home/seumasmac/foo/bar/ in this case.
A destination like myserver:/var/www/ (note: there is a / after the :) is an absolute path. It means the directory /var/www/ on the server.
The error that you get when you try to upload should tell you which of the above is the problem in this case.

Related

SSH Viewing/editing files across multiple accounts [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
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?)?
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.

How to let Dropbox treat symbolic link AS IT IS? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
If I create a symlink inside Dropbox folder, pointing to another file also inside Dropbox folder (say, to maintain certain directory stucture), then Dropbox will try to de-reference the symlink and treat it as an normal file, instead of syncing it as a symlink. This could be very frustrating sometimes since I don't want to copies of the same file.
So my question is, is that a way to let Dropbox sync symbolic link just AS IT IS?
In the cloud the directory structure is not the same as in your computer. Therefore there is no way it will synchronize the symbolic link as it is.
In your computer, the link points to the absolute path to your original file (or folder). It looks like the following:
Original folder path: /Users/username/home/Documents/Dropbox/MyFolder/
Symbolic link: symlink -> /Users/username/home/Documents/Dropbox/MyFolder/
Since the cloud can't point to this same directory structure it will de-reference it and copy your files (on the cloud) all over again.
Links are great in Dropbox when it points to something outside your dropbox folder.
This way the outside files will be copied to the cloud but wont be copied in your computer.
UPDATE:
On the matter of relative symbolic links, I guess Dropbox can't sync as it is because your dropbox directory structure may be different from your colleagues.
For example:
Your structure: Dropbox/Projects/
- coolfile.txt
- SharedDirectory/
Your friend structure: Dropbox/SharedDirectory/
Relative Symbolic link inside SharedDirectory: link -> ../coolfile.txt
The link will work your structure but not on your friends.
UPDATE2: links inside Dropbox are also being used to share content from within a shared folder with someone outside that group.
I've tried doing what you are trying to do. No luck. At the moment there is no way to get dropbox to sync symlinks properly.
However, there is a feature request exactly about this. So cast your votes on the request and hope for the best.

automatic ssh session when moving to mapped sshfs [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
If you have a network drive mapped via sshfs, is there a way to automatically log on via ssh whenever changing to that directory?
$USER:$LOCALHOST:~: sshfs $USER:$REMOTEHOST /Volumes/dev0
$USER:$LOCALHOST:~: cd /Volumes/dev0
$USER:$REMOTEHOST:~
Thomas Jansson provides a guide on integrating sshfs with autofs. I'll summarize his guide here, so this answer will still be worth something if his site ever goes offline:
Create an /etc/auto.master:
/mnt/sshfs /etc/auto.sshfs uid=1000,gid=1000,--timeout=30,--ghost
Make sure your uid and gid match your userid and guid in /etc/passwd or whatever you use to provide system accounts.
Now add lines into /etc/auto.sshfs, one per desired filesystem, in the following form:
bar -fstype=fuse,rw,nodev,nonempty,noatime,allow_other,max_read=65536 :sshfs\#tjansson#bar.com\:
Be sure to change tjansson#bar.com to whatever user account and hostname you're going to be using. Change the leading bar to whatever you'd like the directory to be named. When you cd /mnt/sshfs/bar, autofs will automatically mount the FUSE filesystem for you. Of course, using SSH keys and the ssh-agent(1) will make this far more pleasant.
Update
... create a directory that literally logs you into the other machine.
Hey, that's pretty clever idea. You could either write a shell function that checks the directory name you want to cd into and start a new ssh for you. Maybe you can (ab)use the PROMPT_COMMAND variable to ssh to the host if the directory name matches. Be warned that either approach will slow down your normal cd or every prompt display.
Another approach that I've used and enjoyed is a small little helper script, ~/bin/ssh-to:
#!/bin/bash
hostname=`basename $0`
ssh $hostname $*
Symlink new names to this shell script: ln -s ssh-to sarnold.org and then you can run a command or log in on a remote site without typing the ssh all the time:
sarnold.org python foo.py
It'll log you in to whatever machine you've used for the name of the symbolic link and run whatever command you give it.

Change default file permissions on debian [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I've setup a Debian cloud server. I installed apache, php and then vsftpd. I created users and set permission etc.
When I upload a file, its default permissions are 600 and I can't view the file unless I manually change it to 774 or 775.
So, I'd like to change the default permissions of all files that I upload to /var/www/ to 754.
I know that chmod -R 754 /var/www makes all files within that directory to 774 but it doesn't change the default permissions of all new files that are uploaded.
My user is 'joe' for demo purpose since I'm learning, so I even tried chown -R joe /var/www but that didn't change the default permissions either.
How do I change it default permissions from 600 to 774? In which file should I write and what?
You should use umask. More info here: http://www.cyberciti.biz/tips/understanding-linux-unix-umask-value-usage.html
You must change the umask of the user(s) writing to the directory. And BTW do NOT set execute permissions when they are not needed.
A umask is a negative mask of permissions which should be applied. By default, all files would be created with 666 and all directories with 777. With a umask of 002, which seems to be what you want, these become 664 and 775.
Now, how to set the umask depends on the program which actually writes the file, and whether this setting is available in its configuration file.
Another, less known way, would be to set POSIX ACLs to the upload directory: for this, you can use setfacl with the -d option on /var/www (provided your OS, and filesystem, support it both).
One of your comments suggests you are uploading the files through proftpd. If this is the case, then your question is really specific to that piece of software. The answer is not to go modifying /etc/profile, as that is going to change the default umask for all users that use Bourne Shell or similar (i.e. Bash). Furthermore, a user must actually log into the shell for /etc/profile to be read, and on a properly configured system, the user your daemon is running as does not actually log in. Check http://www.proftpd.org/docs/howto/Umask.html for information specific to proftpd and umasks.

scp error when copying files [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I am trying to use the scp command but I'm getting the following error:
permission denied
lost connection
I get this when I use scp to copy a file from a master node to a slave node.
This is probably more like your error, ya?
Permission denied (publickey).
lost connection
The simplest problem is that you don't have permissions to access the directories specified on at least one end of the copy operation, or you may just have a bad login.
You could try using sudo chown -R
*username* to make sure you have rights to the target directories on
both ends.
Check your directory specifications, make sure that you are using ~/Documents for instance instead of /Documents. Very different locations.
If you've got a bad login, I can't help you there, sorry. Try just ssh-ing into the target(s) make sure you can.
You could check out the manpage for more help
I think error in giving permission to folder which has the authorized_keys file
use chmod and set the permissions