[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 439
  • Last Modified:

Multiple ssh hops to tar to MAC laptop.



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
wotan1953
Asked:
wotan1953
  • 3
  • 2
  • 2
1 Solution
 
omarfaridCommented:
try

ssh user@serverA "ssh user@serverB tar -cf - /path/to/dir" | dd of=/path/to/local/dir/mybackup.tar
0
 
wotan1953Author Commented:
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
 
omarfaridCommented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
TintinCommented:
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
 
wotan1953Author Commented:
Sweet ... this is definitely the way to go. Thanks
0
 
wotan1953Author Commented:
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
 
TintinCommented:
If you have direct access to the server, then you just need

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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now