LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices

Reply
 
LinkBack Search this Thread
Old 11-15-2008, 07:20 PM   #1
dave247
Member
 
Registered: May 2004
Posts: 204

Rep: Reputation: 30
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?
 
Old 11-15-2008, 08:19 PM   #2
MensaWater
Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 5,770
Blog Entries: 4

Rep: Reputation: 697Reputation: 697Reputation: 697Reputation: 697Reputation: 697Reputation: 697
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.
 
Old 11-15-2008, 08:21 PM   #3
dave247
Member
 
Registered: May 2004
Posts: 204

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by jlightner View Post
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?

Last edited by dave247; 11-15-2008 at 08:35 PM.
 
Old 11-15-2008, 08:54 PM   #4
Dutch Master
Senior Member
 
Registered: Dec 2005
Posts: 1,667

Rep: Reputation: 112Reputation: 112
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...

Last edited by Dutch Master; 11-15-2008 at 08:57 PM.
 
Old 11-15-2008, 09:34 PM   #5
MensaWater
Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 5,770
Blog Entries: 4

Rep: Reputation: 697Reputation: 697Reputation: 697Reputation: 697Reputation: 697Reputation: 697
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.
 
Old 11-16-2008, 02:53 PM   #6
jiobo
Member
 
Registered: Nov 2008
Posts: 180

Rep: Reputation: 36
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.
 
Old 11-16-2008, 03:24 PM   #7
Jongi
Senior Member
 
Registered: Aug 2003
Distribution: Debian Sid 32/64-bit, F10 32/64-bit
Posts: 1,070

Rep: Reputation: 45
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" .
 
Old 11-16-2008, 03:50 PM   #8
billymayday
Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 120Reputation: 120
Try
scp "ipaddress://home/user/My\ File.txt"
 
Old 11-21-2008, 01:43 AM   #9
jms1989
LQ Newbie
 
Registered: Sep 2008
Location: USA
Distribution: Ubuntu 7.10
Posts: 11

Rep: Reputation: Disabled
Hi, does scp support wildcards and could copy recursively over the ssh connection?
 
Old 11-21-2008, 03:05 AM   #10
billymayday
Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 120Reputation: 120
Yep........
 
Old 11-21-2008, 06:19 AM   #11
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,570

Rep: Reputation: 510Reputation: 510Reputation: 510Reputation: 510Reputation: 510Reputation: 510
PAss it the -r flag
 
Old 11-21-2008, 08:43 AM   #12
MensaWater
Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 5,770
Blog Entries: 4

Rep: Reputation: 697Reputation: 697Reputation: 697Reputation: 697Reputation: 697Reputation: 697
Quote:
Originally Posted by jms1989 View Post
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.
 
Old 11-21-2008, 09:56 AM   #13
estabroo
Senior Member
 
Registered: Jun 2008
Distribution: debian, ubuntu, sidux
Posts: 1,092
Blog Entries: 2

Rep: Reputation: 109Reputation: 109
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ssh - copying files wendea Linux - Newbie 12 05-25-2007 02:56 PM
Copying files to local computer whilst in ssh tunnel Maverick1182 Linux - Newbie 4 10-07-2006 01:29 PM
Copying .ssh from one server to another xpucto Linux - Newbie 2 07-03-2006 04:52 AM
SSH and remote files yeti.man Linux - Networking 3 09-11-2004 01:08 AM
copy files using SSH from a server to another..both remote Santosh_d Linux - Networking 6 03-10-2004 11:02 PM


All times are GMT -5. The time now is 08:05 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration