Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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@127.0.0.1:/~/fromFolder/ ~/public_directory/toFolder/

where PORT# is an actual port # like 22

I was asked for myuserid@127.0.0.1'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
add comment

1 Answer

The correct syntax would be something like this:

scp -P 234 -r ~/local/directory remoteusername@remotehost.com:/remote/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 - 127.0.0.1 - 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 server1.com
user@local-machine# scp ./somefile.txt user1@server1.com:/home/user2

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

# copy a file from server2.com to server1.com
user@local-machine# ssh user2@server2.com
user2@server2# ls
    somefile.txt    otherfile.txt
user2@server2# scp ./otherfile.txt user1@server1.com:/home/user1
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. –  Bruce Oct 14 '11 at 23:22
add comment

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.