Solved

tar some files on a linux system from a remote unix system and ftp them to the unix system

Posted on 2008-10-02
11
720 Views
Last Modified: 2013-12-27
I want to run tar on a linux system from a SUN Solaris 10 system to tar up a file system and then ftp the tar file to the unix system.  My problem is that I am not the only one using the linux system as root.  I keep putting the tar and ftp in the root cron on the linux system but it keeps getting deleted so I need to figure out a way to run this from my unix system where no one else logs on.  I thought I could use rsh but have never used it before and am not sure what needs to be setup.  I am a bit reluctant to put a .rhost file on this linux system but cannot figure out another way to do the tar and ftp.  I can't change the way the linux system files are setup as they are production and as I said used by others.

Any ideas or suggestions would be really appreciated.

Thanks
0
Comment
Question by:bkreynolds48
  • 4
  • 3
  • 2
  • +2
11 Comments
 
LVL 6

Expert Comment

by:wwnosal
ID: 22623743
You could try to pipe all the commands for creating the tar and sending via ssh, from your Solaris however I'm not sure if it's good idea. Thats just a quick thought.
0
 
LVL 5

Expert Comment

by:awa2008
ID: 22623775
Hello ,

you can found a lot site explain that on typing in google : tar over ssh

http://www.hostinggeek.com/2005/08/tar-over-ssh.html
http://todbot.com/blog/2005/06/26/ssh-and-tar-thru-ssh-gateway/

http://www.cyberciti.biz/faq/howto-use-tar-command-through-network-over-ssh-session/





Using this method effectively sends the compressed tarball to the terminal. You then pipe that into an ssh session which is running the extract version of the previous tar function along with the change directory argument. This, essentially, sends the compressed tarball into a decompression process at the other end over a secure ssh "pipe".

The result is a pretty quick file transfer which - as the data is being sent in a compressed GZIP form (of BZip2 if you replace the z with a j in the tar functions) you save on bandwidth too.

Here an an example of how to do this, assuming you are in (for example) /var/www/html/ and the website you want to transfer is the folder www.example.com.

tar czf - www.example.com/ | ssh joebloggs@otherserver.com tar xzf - -C ~/

This will send the entire www.example.com folder over to the home folder on your target server in compressed form over and encrypted connection.


from : http://www.thingy-ma-jig.co.uk/blog/03-09-2008/using-tar-and-ssh-improve-scp-speeds

Regards
0
 
LVL 1

Author Comment

by:bkreynolds48
ID: 22623778
Can I script using ssh?  How would I enter a password?
0
 
LVL 1

Author Comment

by:bkreynolds48
ID: 22623793
I have a file setup on the linux system to run the tar.
I just need to execute that from the unix system.
Is that possible with ssh?
0
 
LVL 6

Expert Comment

by:wwnosal
ID: 22623798
You can you key file for ssh, then you won't need a password

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 6

Assisted Solution

by:wwnosal
wwnosal earned 100 total points
ID: 22623811
basically it would look more or less like  this::


ssh -i key_file root@your_linux_box "list of commands separated by ; "
0
 
LVL 40

Accepted Solution

by:
omarfarid earned 200 total points
ID: 22623812
both solaris 10 and linux come with ssh. You may

-  set trust between the two systems by exchanging the keys and then you can run

ssh root@linuxhost "tar cvf - /) | dd of=/dev/rmt/0

this will run tar on the remote system and pipe output to the dd command on the local system to the tape device.

to set trust (no password), please see:

http://www.astro.caltech.edu/~mbonati/WIRC/manual/DATARED/setting_up_no-password_ssh.html
http://waelchatila.com/2005/06/06/1118124232757.html
http://www.cvrti.utah.edu/~dustman/no-more-pw-ssh/

0
 
LVL 5

Assisted Solution

by:awa2008
awa2008 earned 200 total points
ID: 22623816
You use a ssh key you have generated before and share between the 2 hostsfrom where you  transfert

you found this from this site:
 http://le-gall.net/pierrick/blog/index.php/2007/09/07/103-ssh-key-authentication-and-batch-mode


SSH, key authentication and batch mode

Par Pierrick, vendredi 7 septembre 2007 à 16:12 / categorie: GNU/linux / tags: / #103 / rss

OpenSSH logo

A long time ago, I've tried to use connect to a SSH server with my private key in a batch mode (with a cron task). I didn't find the way to do it. Now I have. It is as simple as to have no passphrase on your private key. Less secure (but still much more secure than FTP connection) but makes SSH possible in cron task.

$ ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/home/pierrick/.ssh/id_dsa): /home/pierrick/.ssh/id_dsa2
Enter passphrase (empty for no passphrase):
Enter same passphrase again: /home/pierrick/.ssh/id_dsa2.pub.
Your identification has been saved in /home/pierrick/.ssh/id_dsa2.
Your public key has been saved in /home/pierrick/.ssh/id_dsa2.pub.

Add the content of /home/pierrick/.ssh/id_dsa2.pub into remote ~/.ssh/authorized_keys

$ export EDITOR=vi; crontab -e
* * * * * ssh -i /home/pierrick/.ssh/id_dsa2 remote_user@remote_server 'echo $(date) >> /tmp/pierrick.log'

And see that every second, the date is appended to the remote /tmp/pierrick.log
0
 
LVL 6

Expert Comment

by:wwnosal
ID: 22623820
you can generate key file by ssh-keygen (see man on how to do this)
0
 
LVL 1

Author Closing Comment

by:bkreynolds48
ID: 31502359
thanks
0
 
LVL 13

Expert Comment

by:Rowley
ID: 22623879
You can use pass phraseless keys use the SSH_ASKPASS variable. Google "ssh paraphraseless" or "ssh_askpass" for plenty of examples.

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to find files recursively in ftp server quickly? 7 102
Bad Block Relocation for Synchronous GLVM AIX 7.1 2 66
auto mounter on solaris 1 52
Python Assistance 7 73
Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
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…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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.

896 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now