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

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.

Who is Participating?
omarfaridConnect With a Mentor Commented:
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:


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.
Hello ,

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



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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

bkreynolds48Author Commented:
Can I script using ssh?  How would I enter a password?
bkreynolds48Author Commented:
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?
You can you key file for ssh, then you won't need a password

wwnosalConnect With a Mentor Commented:
basically it would look more or less like  this::

ssh -i key_file root@your_linux_box "list of commands separated by ; "
awa2008Connect With a Mentor Commented:
You use a ssh key you have generated before and share between the 2 hostsfrom where you  transfert

you found this from this site:

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
you can generate key file by ssh-keygen (see man on how to do this)
bkreynolds48Author Commented:
You can use pass phraseless keys use the SSH_ASKPASS variable. Google "ssh paraphraseless" or "ssh_askpass" for plenty of examples.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.