Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

The scp (openssh) command accepts relative paths as host:path/ which are relative to the home directory on the host. I would like to change location of the default directory.

For example, I would like to create a shortcure pseudo-host in .ssh/config along the lines of

Host bar
   hostName foo
   ## this directive does not actually exist:
   DefaultDirectory /home/me/some/path/here  

so that I could write

scp some_file bar:baz

instead of

scp some_file foo:some/path/here/baz

Is it possible with openssh?

share|improve this question

3 Answers 3

Another options is of course a small script/function along the lines of (assuming bash here):

myscp() {
  scp ${1%%:*}${SCP_DIR:?/tmp}/${1#*:}
}
share|improve this answer

The quick fix for this is to create a symbolic link in your own home directory on the remote server to the directory that you want to access:

ln -s /your/long/path/here/to/webapp1 ~/webapp1

That would allow you to quickly access the folder like so:

scp file foo:webapp1/

and allow for expansion in the future (more than one remote folder) and it won't break other programs. I've found this to be helpful on my servers when I have several websites running on the same server and I need to push files to them (I mostly use git for this now).

share|improve this answer

The "home" directory is defined by the users' home directory defined in the /etc/passwd file. I don't believe any opensshd parameter will override this behavior. You can change the home-dir of the user... but I don't think this is what you're looking for.

share|improve this answer
    
Eh I know of course where is $HOME defined. And you're right, this is not what I want. –  eudoxos Jan 9 '12 at 14:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.