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
716 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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.

747 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

13 Experts available now in Live!

Get 1:1 Help Now