routerconfigs on cacti 1.1.17 ssh login fails

General discussion about Plugins for Cacti

Moderators: Developers, Moderators

Axel90
Cacti User
Posts: 139
Joined: Fri Feb 10, 2017 12:41 pm

Re: routerconfigs on cacti 1.1.17 ssh login fails

Post by Axel90 »

Hi Pucho,

works for me, too!

Thank you! Great work!

Maybe I'm dumb, but I think the version you can download from github doesn't work for anyone without the changes Pucho figured out.

I'm wondering why noone complained.
Axel90
Cacti User
Posts: 139
Joined: Fri Feb 10, 2017 12:41 pm

Re: routerconfigs on cacti 1.1.17 ssh login fails

Post by Axel90 »

@Pucho

my backups work, but my plugin gets permanently disabled.

Code: Select all

2017/09/19 08:24:14 - ERROR PHP PARSE in  Plugin 'routerconfigs': syntax error, unexpected 'new' (T_NEW) in file: /usr/share/cacti/site/plugins/routerconfigs/Text/Diff.php on line: 330
2017/09/19 08:24:14 - CMDPHP PHP ERROR Backtrace: (CactiShutdownHandler)(/lib/functions.php: 4459 cacti_debug_backtrace)
2017/09/19 08:24:14 - CMDPHP ERRORS DETECTED - DISABLING PLUGIN 'routerconfigs'



Are you in the same situation?
User avatar
Osiris
Cacti Guru User
Posts: 1424
Joined: Mon Jan 05, 2015 10:10 am

Re: routerconfigs on cacti 1.1.17 ssh login fails

Post by Osiris »

What php version? Please open issue on github.
Before history, there was a paradise, now dust.
User avatar
Pucho
Cacti User
Posts: 185
Joined: Wed Jul 20, 2016 8:00 pm

Re: routerconfigs on cacti 1.1.17 ssh login fails

Post by Pucho »

Axel90 wrote:@Pucho

my backups work, but my plugin gets permanently disabled.

Code: Select all

2017/09/19 08:24:14 - ERROR PHP PARSE in Plugin 'routerconfigs': syntax error, unexpected 'new' (T_NEW) in file: /usr/share/cacti/site/plugins/routerconfigs/Text/Diff.php on line: 330
2017/09/19 08:24:14 - CMDPHP PHP ERROR Backtrace: (CactiShutdownHandler)(/lib/functions.php: 4459 cacti_debug_backtrace)
2017/09/19 08:24:14 - CMDPHP ERRORS DETECTED - DISABLING PLUGIN 'routerconfigs'



Are you in the same situation?
I spotted that one I think, worked it through but then I spotted a whole lot more and gave up at this time. Kiwi CatTools does the job a lot much easier for a reasonable price..

I was about to commit all those changes but to be honest I didn't get far enough to worth it.

I'd be surprised the github version is working for anyone..

Some of the issues on github, to me, all related but some of them could be possibly misleading. Mostly because the lack of support/development at the moment. I'd be nice to have it but I haven't used it before so I don't even know if at the end it will give me everything I'd expect to have..

Issue #17
Issue #12
Cacti - 1.2.15
Poller Type - Spine
Weathermap 0.98a
Server Info - Linux 3.10.0 - Centos 7
Web Server - Apache/2.4.6 PHP 5.4.16
MySQL - 5.5 ;RRDTool - 1.4.8 ;SNMP - 5.7.2
Religion - Anti forum pets
seppel
Posts: 2
Joined: Tue Jan 16, 2018 4:35 am

Re: routerconfigs on cacti 1.1.17 ssh login fails

Post by seppel »

I now created two Pull Requests to solve issues in setup.php and function (my first pull requests ever).

https://github.com/Cacti/plugin_routerconfigs/pull/23
https://github.com/Cacti/plugin_routerconfigs/pull/22

Please review this, im a php-noob.

Now i am able to do some backups, but a new problem occurs:
The first backups runs OK but if i run the backup a second time it seems like theres a loop. The Debug Log looks like this:

Code: Select all

0copy run tftp
Address or name of remote host []? Destination filename [<device name>-confg]? <device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#
i will try to get into it today but, as mentioned, im a php noob. can anyone have a look at this?

greets
Axel90
Cacti User
Posts: 139
Joined: Fri Feb 10, 2017 12:41 pm

Re: routerconfigs on cacti 1.1.17 ssh login fails

Post by Axel90 »

Hey seppel,

I tried your 'plugin_routerconfigs-patch-1' and I get the same error:

Code: Select all

2018/01/29 10:26:40 - ERROR PHP WARNING in  Plugin 'routerconfigs': ssh2_auth_password(): Authentication failed for  using password in file: /usr/share/cacti/site/plugins/routerconfigs/functions.php  on line: 666
2018/01/29 10:26:40 - CMDPHP PHP ERROR WARNING Backtrace: (/plugins/routerconfigs/router-devices.php: 135 actions_devices)(/plugins/routerconfigs/router-devices.php: 305 plugin_routerconfigs_download_config)(/plugins/routerconfigs/functions.php: 189 Connect)(/plugins/routerconfigs/functions.php: 666 ssh2_auth_password)(CactiErrorHandler)(/lib/functions.php: 4403 cacti_debug_backtrace)
01/29/2018 10:26:40 AM - ROUTERCONFIGS: 192.168.251.12-> ERROR: SSH login failed
Just want to let you know.

I don't really use routerconfigs anymore. I mean, I got it working with the original branch and Puchos help. So I was able to perform manual backups. But it doesn't do any daily automatic backups. I don't know why. So that's another malfunction. Eventually, I was sick of it.

Now I came back to this thread and saw your updated branch. So I thought, okay let's try it.





PS: I didn't have the problem with the loop. I was able to do more backups - but as I mentioned, only manually.
Last edited by Axel90 on Mon Jan 29, 2018 6:45 am, edited 1 time in total.
netniV
Cacti Guru User
Posts: 3441
Joined: Sun Aug 27, 2017 12:05 am

Re: routerconfigs on cacti 1.1.17 ssh login fails

Post by netniV »

If you are using the latest router-configs from the GitHub repo, you shouldn't be seeing that warning as it is supposed to be suppressed by the leading @.

When attempting to download a configuration, the process gets the account information based on the device ID. Since the password is encrypted it only gets decrypted if a username is set. Otherwise, no account information is returned only FALSE.

Note, there appears to be a bug there in that the $info variable isn't checked for that FALSE return

The code will then first use SSH to connect and failing that Telnet.

When using SSH, ssh2_connect() is called with the device's IP, then ssh2_auth_password() with the account username/password.

Note the username is a maximum of 64 characters and password is a maximum of 256 (encrypted so may be shorter in reality).

I suspect that your password is either not decrypting properly or isn't even set.
Cacti Developer & Release Manager
The Cacti Group

Director
BV IT Solutions Ltd

+--------------------------------------------------------------------------+

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation
netniV
Cacti Guru User
Posts: 3441
Joined: Sun Aug 27, 2017 12:05 am

Re: routerconfigs on cacti 1.1.17 ssh login fails

Post by netniV »

seppel wrote:I now created two Pull Requests to solve issues in setup.php and function (my first pull requests ever).

https://github.com/Cacti/plugin_routerconfigs/pull/23
https://github.com/Cacti/plugin_routerconfigs/pull/22

Please review this, im a php-noob.

Now i am able to do some backups, but a new problem occurs:
The first backups runs OK but if i run the backup a second time it seems like theres a loop. The Debug Log looks like this:

Code: Select all

0copy run tftp
Address or name of remote host []? Destination filename [<device name>-confg]? <device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#
i will try to get into it today but, as mentioned, im a php noob. can anyone have a look at this?

greets
Hi Seppel,

I think the reason is the #. Your device is already authenticated. I suggested some code on some changes another user is currently submitting on the repo which go like this in the functions.php which should be applied to PHPTelnet->Connect():

Code: Select all

$res .= $r;
if (strpos($r, '#') !== FALSE) {
        $enablepw = '';
        break;
} else if (strpos($r, '>') !== FALSE) {
        break;
}
$x++;
So if you search for the '>' in the code, you should find one similar to the above around line 949. Then the following encase all code from the first @fputs to the next @fputs (which has $enablepw) in an if statement:

Code: Select all

if ($enablepw != '') {
@fputs
...
@fputs
}
Cacti Developer & Release Manager
The Cacti Group

Director
BV IT Solutions Ltd

+--------------------------------------------------------------------------+

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation
Axel90
Cacti User
Posts: 139
Joined: Fri Feb 10, 2017 12:41 pm

Re: routerconfigs on cacti 1.1.17 ssh login fails

Post by Axel90 »

Want to give another update:

https://github.com/Cacti/plugin_routerconfigs/issues/26

That version is running fine for me! Without doing any changes to the code.
netniV
Cacti Guru User
Posts: 3441
Joined: Sun Aug 27, 2017 12:05 am

Re: routerconfigs on cacti 1.1.17 ssh login fails

Post by netniV »

Sound likely that your device is self-enabling which means that you don't actually need an enable password but the unpatched code was looking only for the '>' prompt.

There are a few things with that version from a code point of view I've commented on, but nothing that would stop you working hopefully (aside from an incorrect return value).

The other changes are more to do with allowing FTP functionality over TFTP.
Cacti Developer & Release Manager
The Cacti Group

Director
BV IT Solutions Ltd

+--------------------------------------------------------------------------+

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation
Axel90
Cacti User
Posts: 139
Joined: Fri Feb 10, 2017 12:41 pm

Re: routerconfigs on cacti 1.1.17 ssh login fails

Post by Axel90 »

I need an enable password;)
netniV
Cacti Guru User
Posts: 3441
Joined: Sun Aug 27, 2017 12:05 am

Re: routerconfigs on cacti 1.1.17 ssh login fails

Post by netniV »

Makes me more curious now as to which part fixed it for you. As there wasn't that much changed for the download code.
Cacti Developer & Release Manager
The Cacti Group

Director
BV IT Solutions Ltd

+--------------------------------------------------------------------------+

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation
seppel
Posts: 2
Joined: Tue Jan 16, 2018 4:35 am

Re: routerconfigs on cacti 1.1.17 ssh login fails

Post by seppel »

netniV wrote:
seppel wrote:I now created two Pull Requests to solve issues in setup.php and function (my first pull requests ever).

https://github.com/Cacti/plugin_routerconfigs/pull/23
https://github.com/Cacti/plugin_routerconfigs/pull/22

Please review this, im a php-noob.

Now i am able to do some backups, but a new problem occurs:
The first backups runs OK but if i run the backup a second time it seems like theres a loop. The Debug Log looks like this:

Code: Select all

0copy run tftp
Address or name of remote host []? Destination filename [<device name>-confg]? <device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#<device name>#
i will try to get into it today but, as mentioned, im a php noob. can anyone have a look at this?

greets
Hi Seppel,

I think the reason is the #. Your device is already authenticated. I suggested some code on some changes another user is currently submitting on the repo which go like this in the functions.php which should be applied to PHPTelnet->Connect():

Code: Select all

$res .= $r;
if (strpos($r, '#') !== FALSE) {
        $enablepw = '';
        break;
} else if (strpos($r, '>') !== FALSE) {
        break;
}
$x++;
So if you search for the '>' in the code, you should find one similar to the above around line 949. Then the following encase all code from the first @fputs to the next @fputs (which has $enablepw) in an if statement:

Code: Select all

if ($enablepw != '') {
@fputs
...
@fputs
}
I already found the problem, just forgot this post.

https://github.com/Cacti/plugin_routerconfigs/issues/24
i now know the reason for this behavior:
the directory Name must not be the same as the description/hostname.
when you try

copy run tftp://192.168.160.152/SW-DW-OSN1

and "SW-DW-OSN1" already exists as directory -> It fails.

A possible workaround would be to append a ".config" to the filenames.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests