LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-17-2011, 10:15 AM   #1
visitnag
Member
 
Registered: Mar 2008
Posts: 147

Rep: Reputation: 15
using ssh command


Hi,

How can I use ssh command to get a file automatically from a remote server? The following command is working fine...
ssh remote-server "cat /path/to/file" > myfile
but here I have to write the output file name again. Here I am facing one problem. If I have to download some files with comman names, example file1,file2,file3...,file10, I give file*, but this will cat all the files into one output file. I want to copy all the files separately into my server along with the time stamp. In general cp -p command do this in the same server.
 
Old 06-17-2011, 10:21 AM   #2
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 13.1
Posts: 1,326

Rep: Reputation: 253Reputation: 253Reputation: 253
There are several approaches. Use scp:
Code:
$ scp "remote-server:/path/to/dir/*" .
or similar to the command you used with tar:
Code:
$ ssh remote-server "tar -cz *" | tar -xz

Last edited by Reuti; 06-17-2011 at 10:21 AM. Reason: Typo
 
Old 06-17-2011, 11:24 AM   #3
ssrameez
Member
 
Registered: Oct 2006
Location: bangalore
Distribution: Fedora, Ubuntu, Debian, Redhat
Posts: 82

Rep: Reputation: 6
scp -pr remoteserver:<path> <target path> -- to pull files.
scp -pr <path> remoteserver:<remote path> -- to push files.

If you have password less authentication for ssh it will copy all files together without prompting for password.
If not, it will ask for password, for every file getting copied.
 
Old 06-20-2011, 01:11 PM   #4
visitnag
Member
 
Registered: Mar 2008
Posts: 147

Original Poster
Rep: Reputation: 15
Its working fine. Unlike ssh the scp -pr is showing the file download percentage. My remote server is password protected. I have kept the multiple scp commands in a shell to download different files, but one problem I am facing is it is asking password for every file to be downloaded. Cont I use a loop to take the password for every different file to be downloaded automatically?

Last edited by visitnag; 06-20-2011 at 01:13 PM.
 
Old 06-20-2011, 01:17 PM   #5
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 13.1
Posts: 1,326

Rep: Reputation: 253Reputation: 253Reputation: 253
Quote:
Originally Posted by visitnag View Post
My remote server is password protected. I have kept the multiple scp commands in a shell to download different files, but one problem I am facing is it is asking password for every file to be downloaded. Cont I use a loop to take the password for every different file to be downloaded automatically?
I would suggest to move to an ssh-key with passphrase and a running ssh-agent to answer the requests. It’s outlines here, you can skip the final agent-forwarding though in case you have just one remote server.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Remote command execution via SSH and newgrp command SuperMegaMau Linux - General 4 05-13-2011 08:31 AM
[SOLVED] ssh cp command th1bill Linux - General 8 10-30-2010 10:27 PM
ssh's command mode bits Linux - Newbie 3 08-13-2009 07:38 PM
ssh command logging jcookeman Linux - Security 3 08-26-2008 03:50 AM
dsh command using ssh pmrent Linux - Security 2 09-15-2004 11:31 AM


All times are GMT -5. The time now is 08:23 PM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration