?
Solved

Multiple ssh hops to tar to MAC laptop.

Posted on 2009-03-30
7
Medium Priority
?
430 Views
Last Modified: 2012-05-06


Hi-
I need to ssh into server X and then ssh into server Y and tar up a dir (files and dirs), to my MAC laptop. I previously got this from OmarFarid:

ssh username@remoteserver "tar cf - /path/to/dir" | dd of=/path/to/local/dir/mybackup.tar.

I am thinking something like:

ssh username@remoteserver1 | ssh username@remoteserver2  "tar cf - /path/to/dir" | dd of=/path/to/local/dir/mybackup.tar

But not sure. Any help will be appreciated. If by some strange web of circumstances I am right, then the confirmation is still worth 500 pts. I am under the gun on this latest project, and I appreciated you folks help.

Thanks -
0
Comment
Question by:wotan1953
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 40

Expert Comment

by:omarfarid
ID: 24020097
try

ssh user@serverA "ssh user@serverB tar -cf - /path/to/dir" | dd of=/path/to/local/dir/mybackup.tar
0
 

Author Comment

by:wotan1953
ID: 24020387
Hey Omar-

Thanks :

Here is what I get :

name@server.com's password:
Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password,keyboard-interactive).
0+0 records in
0+0 records out
0 bytes transferred in 43.284073 secs (0 bytes/sec)
bash-3.2$

I doubled checked to see if password was correct, but no go:

I even tried:
ssh user@serverA "ssh serverB tar -cf - /path/to/dir" | dd of=/path/to/local/dir/mybackup.tar

That is no user on second ssh, because login name the same ... to no avail. Any idears?

Thanks Again
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 24021559
It seams that running the commands the way I described have problems in stdin redirection. The easiest way is to login to serverA via ssh ; then run

ssh user@serverB "tar cf - /path/to/dir" | dd of=/path/to/backup/serverB.tar

then logout from serverA, and run the below command on laptop

scp username@serverA:/path/to/backup/serverB.tar /path/to/dir/serverB.tar

0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 48

Accepted Solution

by:
Tintin earned 2000 total points
ID: 24025993
No need for two lots of tar.

You can do it via an ssh tunnel.

First set up your tunnel

ssh -L 222:serverB:22 user@serverA

then in another window, you can talk directly to serverB via the tunnel, eg:

ssh -p 222 user@localhost "tar cf - /path/to/dir" | dd of=/path/to/backup/serverB.tar
0
 

Author Closing Comment

by:wotan1953
ID: 31564372
Sweet ... this is definitely the way to go. Thanks
0
 

Author Comment

by:wotan1953
ID: 24031203
hey I am asking another one:

Title: copying files across servers to my Mac laptop.

Question: I need to copy extra dirs/files from an external server, to my Mac Laptop.

I was thinking something like:

ssh username@remoteserver "scp /etc/mail/aliases_03032009.txt" | dd of=/path/to/local/dir//aliases_03032009.txt
         
0
 
LVL 48

Expert Comment

by:Tintin
ID: 24032733
If you have direct access to the server, then you just need

scp user@remoteserver:/etc/mail/aliases_03032009.txt .
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded‚Ķ
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question