Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to SCP some files from my local Ubuntu 10.04 Virtual Machine (running on a Windows Vista Platform) up to my remote web host. SSH is enabled on their end and I was able to login via the command line so I know I'm using the right port #. Here is what I tried:

I login in to the web host via SSH shell. Then at the command prompt "remoteuser@remotehost" I type:

scp -P PORT# -r myuserid@ ~/public_directory/toFolder/

where PORT# is an actual port # like 22

I was asked for myuserid@'s password but it wouldn't take the password I normally use with this localhost account.

What is the best way to use scp? Do I login the remote host via SSH and then run scp at the command prompt remoteuser@remotehost$ or should I just run SCP from my localhost?

share|improve this question

The correct syntax would be something like this:

scp -P 234 -r ~/local/directory

The code you've shown tries to copy files from your local machine accessed via localhost to your local machine accessed directly

UPDATE: If you're trying to issue the scp command from an ssh session on the remote host to copy files back to your virtualbox Ubuntu, then I'm afraid it's not impossible in most cases - i.e. most likely the virtualbox Ubuntu instance can't be connected to from the outside world unless you did some setup (i.e. set up a bridged adapter in your host OS, configured port forwarding on the modem etc.). Moreover, the IP address you're trying to use - - is a "local loopback" address and is only accessible from the same machine. I.e. when you run the command on the server, this IP refers to the server.

So I'm still suggesting you to use the syntax I showed above - just keep in mind that "local" in the command means "the machine on which you have a terminal session open", not the physical machine you're sitting at.

Example: if you wan to copy a file from one server to another:

# copy a file from local machine to
user@local-machine# scp ./somefile.txt

# copy a file from to
user@local-machine# ssh
user1@server1# scp ./somefile.txt
user@server1# logout

# copy a file from to
user@local-machine# ssh
user2@server2# ls
    somefile.txt    otherfile.txt
user2@server2# scp ./otherfile.txt
user2@server2# logout

# can't copy a file TO local-machine because it's not accessible from internet
share|improve this answer
Thanks Sergey...I edited my ? above...I am logging into the remote host via SSH. If I try doing as you say above I get a msg saying "/remotusername/directory no such file or directory"....Basically it thinks the source directory is the remote host instead of the machine I am trying to copy from - which is the localhost. – Nona Oct 14 '11 at 23:22

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.