Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Im wondering what the quickest way for this is

On my local computer I have a file in /some/long/path/name

When i have SSH'ed into another machine I decide I want the local file to go in /remote/long/dir/

I then open a new shell, scp the file to home, switch back to the first shell and mv the file from home to the current directory.

I find this way easier due to tabbed completion etc.

Is there a "trick" to make scp use the files from the computer connecting to it show in the remote ?

i guess example syntax would be (to be run on the remote machine)

scp host:/tabbed/complete/file file

or would i alawys need a second connection if i decide half way though ?

The computers i connect from dont have direct port access from outside

share|improve this question
If you've set up public key authentication for the SSH connection to the remote host, your local bash or zsh should provide tab-completion for the remote filesystem when you type something like scp remotehost:/h and press <tab>. The completion might be a little unresponsive, depending on your network connection, but it's definitely worth a try for long path names. – Aug 18 '13 at 0:56
My key has a password, is this still possible ? –  exussum Aug 18 '13 at 0:57
I don't think so. bash/zsh has to establish an SSH connection to provide the completion, which it can't when it would have to prompt you for a password (be it the remote system's password or the one for your key). – Aug 18 '13 at 1:01

2 Answers 2

These are on LAN correct? You can use sshfs to mount the remote directory on your local machine.

Create a mountpoint

sudo mkdir -p /mnt/remotehost
sudo chmod 777 /mnt/remotehost

Mount the remote share

sshfs user@remotehost:/home/user /mnt/remotehost

Use the remote share

ls /mnt/remotehost
cp /mnt/remotehost/Documents/*.odt ~/Documents/

Unmount the remote share

fusermount -u /mnt/remotehost

Keep in mind this is much slower than just scp'ing the files but may prove faster in the long term if you are having to manually check each time. This also gives you the advantage of using a graphical filemanager (slow, especially if it starts creating thumbnails).

share|improve this answer
no - just internet access. ssfs wouldnt allow me to use other commands on the remote. Also sshfs is fairly slow sometimes. sshfs is great though for the tabbed completion –  exussum Aug 18 '13 at 0:40

From the comments, thanks to for this one.

Save public key

ssh-copy-id user@remotehost

Configure bash

  • Install the bash-completion package


Configure zsh

  • Install the zsh package
  • zsh
  • Continue to main menu 1
  • Configure the new completion system 2
  • Run the configuration tool (compinstall) 2
  • Write to ~/.zshrc Enter
  • Continue Enter
  • Continue Enter
  • Save and exit 0
  • Save new settings y
  • Set new styles for immediate use y
  • Quit and do nothing else q

scp with remote tab-completion

scp user@remotehost:/Tab

share|improve this answer
This can be improved slightly - you can use ssh-agent to remember the key for your session, then start as many ssh sessions as you like without reentering the key, and use tab-expansion as you suggested. (To use ssh-agent, type ssh-agent /path/to/private-key, enter in your private key and then start ssh sessions as normal (or use SCP with tab expansion) –  davidgo Aug 18 '13 at 3:51

Your Answer


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.