need help scripting tar over ssh


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting need help scripting tar over ssh
# 1  
Old 10-23-2007
need help scripting tar over ssh

Hello - I've used 'expect' in FTP scripts before without any problems, but am unsure as to how I would script a tar over ssh session?

I need to send password for authentication to the remote Suse machine.

Smilie


Any assistance provided would be GREATLY appreciated.
# 2  
Old 10-23-2007
I've used the following post as reference before:

HTML Code:
https://www.unix.com/unix-advanced-expert-users/14417-loops-within-ftp-comands.html
Hope it helps.
# 3  
Old 10-23-2007
Quote:
Originally Posted by bd_joy
I've used the following post as reference before:

HTML Code:
https://www.unix.com/unix-advanced-expert-users/14417-loops-within-ftp-comands.html
Hope it helps.
Thanks. That is good to know, but unfortunately it's not what I need. I have a lot of data (every directory off of root filesystem) to transfer to a remote server nightly.

I would like to use a command similar to this:

# tar cvf - /var | ssh user@remoteserver 'tar xvf -'

...the problem is I have not been able to get this to work within an 'expect' script.

Is it possible to do so? Due to security restrictions, all accounts on the remote server must have passwords, so I must send the password in the script.
# 4  
Old 10-23-2007
If you use ssh, why don't you exchange ssh-keys to circumvent the need for a password? Just create the key (see: ssh-keygen) without a password and put it into the file authorized_keys.

bakunin
# 5  
Old 10-24-2007
Thx bakunin -

I had just discussed this with a co-worker here and it may be an option although we currently don't have sshd running on the local UnixWare servers. It is installed and running on the remote Suse Linux server that we are transferring the files too, though.

I assume sshd must be installed and running on both machines, but it shouldn't be a problem.
# 6  
Old 10-25-2007
I was a bit short on my answer, so here is the long version:

You can't do, what you (originally) wanted to do, because

1. using the <stdin> of ssh to transport some file like in "proc | ssh ..." make this <stdin> unusable for any other purposes, namely input of passwords. This is a general problem, which is: "proc1 | proc2 < file3" is not possible because <stdin> of proc2 can either accept input from proc1 OR from file3 but not both.

2. to be reasonably eligible to do input processing as a means of file transfer (the "proc | ssh ...") ssh must make sure its <stdin> is not used elsewhere, especially not input. This (and because of some security reasons like reading the terminal session at the terminals device file) is why ssh doesn't use <stdin> to get the password but reads directly from the keyboard. I'd be very much surprised if expect is able to emulate this.

So, the bottom line is: i haven't ever needed to work with expect, so my experience is limited, but probably passing passwords to ssh is impossible.

bakunin
# 7  
Old 10-25-2007
Thanks for your input. I was able to run ssh-keygen and get the trusted relationship set up. It works perfectly.

Thanks again.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Ssh tar file using slave node

Hi, I wanted to zip some files (very large files) on our cluster (centOS). I am told that I should use the head node for this as it would tie down the CPU. How can I do this using one of the other nodes in the cluster? For small files, I would just log into the cluster using ssh (ie. ssh... (1 Reply)
Discussion started by: pc2001
1 Replies

2. Shell Programming and Scripting

Help with ssh,tar and logging

Hi, I'm successfully written a script which tar a directory and ssh's it over a remote server tar cfv - $SDIR | ssh $RHOST "cat > $DDIR/backup.$BKPEXT.tar" However, Im unable to log the activity to a file. i.e for example if I do tar cfv - $SDIR | ssh $RHOST "cat >... (1 Reply)
Discussion started by: maverick_here
1 Replies

3. Shell Programming and Scripting

Need some help in bash scripting with ssh

Hi @ all I have the following scenario: As Admin of a cupple of servers I tried to write the following script to figure out, if the machine is up and available and if some directory´s were available. But my script is having some probs, while running. Maybe some of you have a better way to... (9 Replies)
Discussion started by: muogli
9 Replies

4. Shell Programming and Scripting

expect script pushing ssh keys w/ tar extract

ok, I'm new to the forum and I did a few searches and didn't find much on this so here goes. I have a ksh I use to call an expect script that opens a ssh session and then extracts a tar file. The tar file has my prefered .profile and my ssh keys. I want to run this script 1 time on new servers and... (2 Replies)
Discussion started by: gtsonoma
2 Replies

5. Shell Programming and Scripting

Scripting ssh question

I am new here so I apologize if this question is in the wrong section or outside of the realm of this board. Also, this is just my first week into shell programming so I am probably doing lots of things wrong. I am trying to write a script to ssh to a machine as one user and then run a command... (0 Replies)
Discussion started by: Parva
0 Replies

6. Red Hat

tar/untar over ssh

I use red hat linux. I have two linux server . I want to use tar over ssh to tar and untar the file. The server A , have IP 10.1.1.a ,there is dir a and contain files. The server B have IP 10.1.1.b , there is dir b and contain file . So, in above case ,how can I tar over ssh sunc that the file... (0 Replies)
Discussion started by: chuikingman
0 Replies

7. Shell Programming and Scripting

SSH and AWK Scripting

I am trying to put an awk command in ssh, for example: ERRCOUNT=`ssh -n $HOST "ps -ef | grep .job | grep -v grep | grep -v alert_jobs_still_running |wc -l"` From korn shell prompt this works: awk '/^Jul 12 16/ {print $0}' /u01/app/oracle/jobs/adhoc/test.dat | wc -l My data file:... (3 Replies)
Discussion started by: bradyd
3 Replies

8. UNIX for Dummies Questions & Answers

TAR OVER SSH

Hello, I have a server that has a tape drive attached to it in our company's DMZ. I want to backup the data on other servers onto this tape drive using a script. I will have to ssh into each machine and execute a tar command and instruct the tar command to send the data back to the server that... (5 Replies)
Discussion started by: mojoman
5 Replies

9. Shell Programming and Scripting

ssh scripting

Hi, I'm trying to write a script that will ssh into a number of boxes and run 'top' and 'ps', then output the results to a file with the hostname. The script only seems to run top or ps on the local machine though. Any help would be apperciated #ssh into box while read box do ssh -n $box ... (3 Replies)
Discussion started by: Brimak86
3 Replies

10. Shell Programming and Scripting

scripting an ssh session?

I know the root login/password for a machines, and I want to automate some commands like this from each: ssh root@remoteHost1 "tail /var/log/messages" ssh root@remoteHost2 "tail /var/log/messages" ssh root@remoteHost3 "tail /var/log/messages" ssh root@remoteHost4 "tail /var/log/messages" ssh... (2 Replies)
Discussion started by: jjinno
2 Replies
Login or Register to Ask a Question