http://www.perlmonks.org?node_id=257705

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi All,

I am looking for a program or script that will do the following:
1. Login to my linux box via ssh using a keyfile & password
2. Copy all files from /var/BACKUP to the local machine

Its going to be used to move daily backup files off my server on to a local machine. The local machine can be running either windoze or linux - just incase anybody knows of any windows programs that will do this :-/

Replies are listed 'Best First'.
Re: moving files via ssh
by zby (Vicar) on May 13, 2003 at 12:35 UTC
    Two things (that can help): scp (command similar to unix rcp, and cp, but working with the SSH protocol), and rsync (which can synchronize directories over SSH).
Re: moving files via ssh
by december (Pilgrim) on May 13, 2003 at 13:00 UTC

    You don't need anything else than ssh (more exactly, scp) when both machines are running Linux (or some other unix). Just use 'scp -r backup@backupmachine:/var/BACKUP /var' or something. The key thing will happen automatically; and if you use a dedicated 'backup' user, this is a quite secure solution.

    I don't know anything about windows, except that it won't natively interact with any open, non-MS technology. I guess there must be some third-party programs with similar functionality. Perhaps openssh itself, with cygwin...

      Cygwin is pretty good anyway. You can get a complete OpenSSL and OpenSSH suite for Cygwin, and it's works well enough.

      If you are adicted to a GUI then PuTTY is pretty good, and includes a nice SSH terminal tool, and a set of batch-able command line tools.

      You should also be able to get various SSH tools for Perl from CPAN, but I've not used them, and I don't know if they are easy to get for Windows either.


      --
      ajt
      Cheers. How does the key thing happen automaticaly? i have a key file for the machine, do i need to copy this to any specific directory? i realy want this copy to run overnight (non-interactivly), so i don't want it asking for passwords or locations of key files.
        Simple summary:

        challenge-response authentication. Generate your ssh-keys with <ssh-keygen -d> for ssh2. You will have the files $HOME/.ssh/id_dsa.pub and $HOME/.ssh/id_dsa. The id_dsa.pub - file is your public key. Copy that file to the target + to $HOME/.ssh/machinename.pub and do a "cd .ssh; cat machinename.pub >>authorized_keys". Now you should be able to connect to the target machine via ssh without using passwords.
        On a unix box you achive this by the cron daemon. The documentation how to use it you can find with: man crontab.
Re: moving files via ssh
by powerhouse (Friar) on May 13, 2003 at 14:19 UTC
    Here is one that I use, and I love it... However you have to do it manually, it does not do it for you, at least the version I have. They do have multiple versions :o).

    Program named: SSH Secure Shell
    Company: SSH Communications Security
    Website: http://www.ssh.com/products/

    Hope that helps your search...

    thx,
    Richard