Jump to content

how do I cp a file from an ssh session to the PC where I am.


JeroenM
 Share

Recommended Posts

From the computer you login on and the directory where you want the file;

 

scp user@IP:/fullpath/to/file/filename .

 

That is the command I use to copy files using ssh, the key is the dot specifying that you want to copy the file/s to where you are currently located.

Link to comment
Share on other sites

just wanted to add to Relic2K's comment that you can also use the normal regular expression in the scp command.

 

i.e

 

scp <user>@<ip addr>:/dir/* .

 

will copy all the firles in the directory without prompting you for each one, unless you have a file locally of the same name then it may propmt you to overwrite it.

Link to comment
Share on other sites

Also, kinda after the fact since you got it working, but you could have used rsync to perform the operation:

rsync -av -e ssh <username>@<address>:<remote dir> <local dir>

This does a bit more then just copying files (was created I believe as some type of version managment tool) and will only transfer changes to the files so it will save time after the first run.

Link to comment
Share on other sites

scp works. Just take the manual.

 

Sorry, but it is as easy as this post is short :)

 

Hmm

in that case my intelligence is as low as your post was short. ;-)

 

first I ssh to the box, give the password to get in.

ls to find the file

scp and now what?

scp filename ip-adresOfTheBoxImAt:filename ???

doesn't work.

 

No, don't ssh in. You can use pscp from putty, and you would do (from the client):

 

pscp server:/path/file .

 

(in the simpest form), or using scp if you have the cygwin ssh stuff.

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...

Obviously, just like ftp requires an ftp server running at the remote machine, sftp requires a sftp-server running too (in my case /usr/lib/ssh/sftp-server). I use gftp, which supports the use of sftp-server if you use SSH2 as your connection type.

Link to comment
Share on other sites

I did a little looking on google and it seems that you are right - scp will copy files between computers using ssh. However, this is not a simple process and involves creating enryption keys and the such.

 

my experience with scp is that no encryption keys are required.

If you are not using NIS for centralized user database, all you have to do is that the user you are trying to send files as from the source also exists on the target exAcTlY as it does on the source.. why the case issue on exactly? case matters.. might even want to make sure the password is the same. Of course if you have root password on both machines, that is easiest as you will never run into permission issues when transferring.

scp localfile.txt root@192.168.1.5:/home/otheruser/tmp

is a good example. It will simply ask you for a password.

If you think that is cool and also (like me) have to subject yourself to windows, try using the pscp utility that comes with putty. Now that ROCKS!!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...