LINUX.ORG.RU

Backup Во что бы то ни стало!


0

0

Ситуация такая, нужно сделать бэкап и послать архив на другой сервер. Пробовал с помощью утилиты FTP - дома работает - на работе глюк утилиты, по сему сей вариант не предлагать. Сейчас пробую с помощью SCP, но проблема с вводом пароля... т.к. все работает автономно пишу скрипт на шеле:

scp ./$prefix.tgz $usrname@$usrhost:/home/$usrname/$prefix.tgz <<END_SCRIPT
quote PASS $usrpass
END_SCRIPT


Но так оно не срабатывает, все равно запрос пароля идет на консоль. Подскажите плиз-з =)

(кста $usrname:$usrpass@$usrhost тоже не работает)

anonymous

Ответ на: комментарий от anonymous

А что там SSH пароль как-то подругому спрашивает?

anonymous
()

lftp -f cmd

$ cat cmd

open backserv
put bak.gz
bye
==

(backserv) алиас=ftp://backup:backup@192.168.0.2/bak

???

perf
()

ssh умеет брать пароль не только с клавиатуры, но и авторизироваться с помощью секретного ключа в файле

Потом, ipsec можно поднять..

dilmah ★★★★★
()

Используй ftp. Любой ftp умеет пакетный режим, даже на винде(вроде -s)

Deleted
()

use POSIX qw(:sys_wait_h setsid);
use Symbol;
use strict;

my $progname = $0;
my @exit_hook;

END { map {&$_} @exit_hook }

sub start
{
  shift;
  my $pid = fork;
  die "fork: $!" unless (defined $pid);
  if ($pid == 0) # child
    {
      # dissociate from controlling tty because openssh client will insist
      # on reading password from controlling tty if it has one.
      setsid ();
      exec (@_) || die "exec: $_[0]: $!";
    }
  return $pid;
}

sub exitstat
{
  my ($pid, $nowaitp) = @_;
  return undef if (waitpid ($pid, ($nowaitp? WNOHANG : 0)) == -1);
  return WEXITSTATUS ($?) if WIFEXITED   ($?);
  return WTERMSIG    ($?) if WIFSIGNALED ($?);
  return WSTOPSIG    ($?) if WIFSTOPPED  ($?);
  return undef;
}

# These are not meant to be cryptographically secure; they are just meant
# to obfuscate sensitive data so they are not discovered accidentally.

sub scramble
{
  local $_ = shift;
  tr/[\x00-\x7f][\x80-\xff]/[\x80-\xff][\x00-\x7f]/; # rot128
  $_ = $_ ^ ("\xff" x length ($_));                  # invert bits
  s/(.)/sprintf "%02x", ord($1)/ego;                 # base16-encode
  return $_;
}
sub unscramble
{
  local $_ = shift;
  s/(..)/chr hex $1/ego;                             # base16-decode
  $_ = $_ ^ ("\xff" x length ($_));                  # invert bits
  tr/[\x00-\x7f][\x80-\xff]/[\x80-\xff][\x00-\x7f]/; # rot128
  return $_;
}

sub handle_subcall
{
  # We might be invoked to inquire whether or not to
  # connect to a host for which we have no stored key;
  # if that happens, inquire from user.
  if ($ARGV[0] =~ m|yes/no|o)
    {
      print STDERR $ARGV[0];
      my $ans = <STDIN>;
      print $ans;
      return;
    }

  print unscramble ($ENV{_ssp_data}), "\n";
}

sub main
{
  unless (@ARGV)
    {
      print STDERR "Usage: $0 [command {command args...}]\n";
      exit (1);
    }

  unless ($progname =~ m|^/|)
    {
      use Cwd;
      my $pwd = getcwd ();
      $progname =~ s|^|$pwd/|;
    }

  # In order to determine whether this script is being invoked by the user
  # or invoked recursively via ssh to fetch a password, we inspect several
  # conditions:
  #   * env var is set (containing password)
  #   * ssh_askpass env var is set to this program
  #   * 1 arg (a prompt) is passed from ssh client
  #   * output is not a tty
  #
  # If any of these conditions fail, we assume this is a primary invocation
  # and therefore query user for a password and launch a command.
  return handle_subcall ()
    if (exists $ENV{_ssp_data}
        && exists $ENV{SSH_ASKPASS}
        && $ENV{SSH_ASKPASS} eq $progname
        && @ARGV == 1
        && ! -t 1);

  # If display is not already set, we must set it now or ssh will not
  # invoke the askpass program.  Since we are performing a non-interactive
  # response we don't really need a display.  We use an invalid display
  # name to prevent any inadvertent grants of X access on remote hosts.
  $ENV{DISPLAY} = "none." unless exists $ENV{DISPLAY};
  $ENV{SSH_ASKPASS} = $progname;
  $ENV{_ssp_data} = @ARGV[0];
  print "_ssp_data is " . $ENV{_ssp_data} . "\n";

  my $pid = start (@ARGV);

  # This signal handling will be imperfect, since any jobs running under
  # the immediately inferior process may not receive any signals; since the
  # child process has no controlling tty, process groups will not work.
  # Usually this will not be a concern unless running commands under a
  # shell started via this wrapper.
  my $sighandler = sub { kill $_[0], $pid };
  map { $SIG{$_} = $sighandler } qw(HUP INT QUIT TERM TSTP);
  exit (exitstat ($pid));
}

main ();

kmeaw ★★★
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.