2

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 [email protected]:/~/fromFolder/ ~/public_directory/toFolder/

where PORT# is an actual port # like 22

I was asked for [email protected]'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?

1 Answer 1

2

The correct syntax would be something like this:

scp -P 234 -r ~/local/directory [email protected]:/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 [email protected]:/home/user2

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

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

# can't copy a file TO local-machine because it's not accessible from internet
1
  • 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, 2011 at 23:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .