Re: [Ssh-sftp-perl-users] Scp capability but no sftp capability
Brought to you by:
dbrobins
From: Heiko J. <ja...@hb...> - 2008-01-17 08:20:46
|
Am Mittwoch, den 16.01.2008, 23:13 +0100 schrieb Mik J: > > > I'd suggest using Net::SCP (which is only a wrapper > > around the command line scp) > > I can't use the Net::SCP for the reason below > "Q: How do you supply a password to connect with ssh > within a perl script using the Net::SSH module? > A: You don't (at least not with this module). Use RSA > or DSA keys. See the quick help in the next section > and the ssh-keygen(1) manpage. > A #2: See Net::SCP::Expect instead. > " > My routers accept only password authentication. So you try Net::SCP::Expect instead, as proposed. > I did not manage to make Net::SSH2 with the scp option > to work when trying to secure copy my router's > configuration. > > #!/usr/bin/perl > use Net::SSH2; > $cisco = '10.1.1.1'; > $user = 'miky'; > $pass = 'mypass'; > $cfg_run = 'RUNCFG'; > $cisco_run = 'running-config'; > my $ssh2 = Net::SSH2->new(); > $ssh2->debug(1); > $ssh2->connect($cisco) or warn "Can't open connection > to $host\n"; > $ssh2->auth_password($user, $pass); > $ssh2->scp_get($cisco_run,$cfg_run); > print "\n"; > > > $ ./scpcisco.pl > libssh2_scp_recv(ss->session, path, &st) -> 0x0 > Net::SSH2::DESTROY object 0x80e0d40 > and the file RUNCFG is not created First, make sure you have libssh2 0.18 and Net::SSH2 0.18. Previous versions had problems. Even though I have these versions your script did not work for me at first either: when I started it, it simply hang without printing any debug messages... I had to replace "auth_password" with "auth_keyboard" to get it to work. However, I could test that only with a linux server running OpenSSH - I do not have a cisco router here for testing so my solution might no be applicable to your environment. Heiko |