LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (https://www.linuxquestions.org/questions/debian-26/)
-   -   copying files from remote server through ssh (https://www.linuxquestions.org/questions/debian-26/copying-files-from-remote-server-through-ssh-683673/)

dave247 11-15-2008 07:20 PM

copying files from remote server through ssh
 
so I was trying to copy a file from my class server through ssh from the terminal by typing 'cp file destination' but I cant get it to copy from there to my system at home. However, if I run the ssh gui program from xwindows, I can view the connection as a folder and I can browse with my mouse and copy the files. So I know I should be able to copy them with a simple command, right?

what am I not doing?

MensaWater 11-15-2008 08:19 PM

ssh is not a copy utility. However, if you have ssh access you should be able to use scp or sftp to do the copy instead. Both of these will use the ssh setup to do the file transfer.

dave247 11-15-2008 08:21 PM

Quote:

Originally Posted by jlightner (Post 3343275)
ssh is not a copy utility. However, if you have ssh access you should be able to use scp or sftp to do the copy instead. Both of these will use the ssh setup to do the file transfer.

Well what is the ssh gui utility using when it allows me to copy the files?

In Debian, I go to the Connect to Server application and connect through ssh... I am able to browse and copy files. It's ssh right? Or not fully?

Dutch Master 11-15-2008 08:54 PM

Under the hood that gui uses scp. Which in turn relies on ssh for security. A gui is just that: a graphical user interface. By definition it's not a program by itself, it's just a (pretty) shell surrounding the actual program that does the work for those that can't or won't want to work from the commandline...

No, ssh is only the secure connection. By itself ssh can't copy files. But if you insist, by all means: go ahead... :rolleyes:

MensaWater 11-15-2008 09:34 PM

In fact there is even a MS Windows GUI utility for scp called, not surprisingly, WinSCP. It lets you drag and drop as well.

However you said you wanted to do command line (CLI) and as both I and DutchMaster have explained the CLI command to use that goes over the same port as ssh is scp and sftp. There is no law requiring you to use CLI but your question seemed to imply you wanted to learn how.

While you COULD actually create what is called an ssh tunnel and then do cp over that only God knows why you'd bother when scp/sftp are sitting there for that very purpose and all you have to do is launch the appropriate command.

Off on a tangent:
Back when I was learning UNIX and most communications were serial connections (usually over modem) there was a utility called "cu" that let you do the connection but also let you do ~put and ~get to transfer files using the same connection session. I've sometimes wished that ssh had a similar facility built in simply to avoid running a separate command when I wanted to quickly copy a file. Alas it is not so for ssh and on a multiuser/multiprocess OS like UNIX/Linux it really isn't that big a pain to launch a separate window for the command.

jiobo 11-16-2008 02:53 PM

SCP will work
 
Quote:

so I was trying to copy a file from my class server through ssh from the terminal by typing 'cp file destination' but I cant get it to copy from there to my system at home.
From your system at home, you would use the "scp" shell command to connect to the class server via ssh and tell scp what file to copy.

> scp server@<ip_of_server>:file newfile

To put a file onto the server,

> scp file server@<ip_of_server>:newfile


Quote:

you should be able to use scp or sftp to do the copy
If you have the ssh server running on one machine, then yes, it will work if you can reach that machine through your network.

Jongi 11-16-2008 03:24 PM

When using scp, how does one go about copying say a file called My File.txt? I've tried

scp ipaddress://home/user/My\ File.txt .
scp "ipaddress://home/user/My File.txt" .

billymayday 11-16-2008 03:50 PM

Try
scp "ipaddress://home/user/My\ File.txt"

jms1989 11-21-2008 01:43 AM

Hi, does scp support wildcards and could copy recursively over the ssh connection?

billymayday 11-21-2008 03:05 AM

Yep........

AlucardZero 11-21-2008 06:19 AM

PAss it the -r flag

MensaWater 11-21-2008 08:43 AM

Quote:

Originally Posted by jms1989 (Post 3349588)
Hi, does scp support wildcards and could copy recursively over the ssh connection?

Yes.

If you're transferring an entire directory structure that contains symbolic links you might want to use rsync instead. scp/sftp won't handled symbolic links.

estabroo 11-21-2008 09:56 AM

If you still want to use cp, you could always use sshfs and mount the remote site as a local directory and then just cp like normal.


All times are GMT -5. The time now is 02:53 PM.