Log in to cacti from shell script
Moderators: Developers, Moderators
-
- Posts: 6
- Joined: Sat Apr 06, 2019 10:08 pm
Log in to cacti from shell script
Hello.
I'm trying to log in to my cacti server from a shell script (to export graph's csv) but i cant seem to get it working..
Cacti server has built in auth enabled.
I have tried using wget with next params:
wget --posta-data 'action=login&login_username=$USER&login_password=$PASS' --keep-session-cookies --save-cookies=cookies.txt http://my.server/cacti/
wget --load-cookies=cookies.txt $CVS_URL -O myfile
all i get is the login page..
thank you in advance for any help..
Regards,
Ramiro.
I'm trying to log in to my cacti server from a shell script (to export graph's csv) but i cant seem to get it working..
Cacti server has built in auth enabled.
I have tried using wget with next params:
wget --posta-data 'action=login&login_username=$USER&login_password=$PASS' --keep-session-cookies --save-cookies=cookies.txt http://my.server/cacti/
wget --load-cookies=cookies.txt $CVS_URL -O myfile
all i get is the login page..
thank you in advance for any help..
Regards,
Ramiro.
Re: Log in to cacti from shell script
The problem will be that you are posted within the CSRF token. That will prevent you from doing so to stop CSRF attacks.
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
The Cacti Group
Director
BV IT Solutions Ltd
+--------------------------------------------------------------------------+
Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation
-
- Posts: 6
- Joined: Sat Apr 06, 2019 10:08 pm
Re: Log in to cacti from shell script
Hello @netniV, thank you for your response.netniV wrote:The problem will be that you are posted within the CSRF token. That will prevent you from doing so to stop CSRF attacks.
I found out that commenting lines that refer to CSRF in global.php solve the problem, but I'm sure this is not the safest way to go..
What would be the correct way to achieve this and bypass the login page? is it possible using wget or curl?
Thank you very much.
Ramiro.
Re: Log in to cacti from shell script
If you are using Cacti 1.1.20 or later, you can utilise my tokenauth plugin which allows you to generate a daily token to be used on a GET instead of a POST. That then bypasses the CSRF check since there is no posted data.
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
The Cacti Group
Director
BV IT Solutions Ltd
+--------------------------------------------------------------------------+
Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation
-
- Posts: 6
- Joined: Sat Apr 06, 2019 10:08 pm
Re: Log in to cacti from shell script
Hello netniV, my bad i havent posted my cacti version. We use version 0.8.8g.netniV wrote:If you are using Cacti 1.1.20 or later, you can utilise my tokenauth plugin which allows you to generate a daily token to be used on a GET instead of a POST. That then bypasses the CSRF check since there is no posted data.
Is there any compatible version of the plugin for this deployment?
thanks.
Ramiro.
Re: Log in to cacti from shell script
I have never used anything lower than 1.1 so it could probably be made to work but I wouldn't be sure how.
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
The Cacti Group
Director
BV IT Solutions Ltd
+--------------------------------------------------------------------------+
Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation
Re: Log in to cacti from shell script
There again, it may rely on hooks only available in later versions of cacti...
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
The Cacti Group
Director
BV IT Solutions Ltd
+--------------------------------------------------------------------------+
Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation
-
- Posts: 6
- Joined: Sat Apr 06, 2019 10:08 pm
Re: Log in to cacti from shell script
OK, thank you very much for all your help!netniV wrote:There again, it may rely on hooks only available in later versions of cacti...
Ramiro.
Who is online
Users browsing this forum: No registered users and 1 guest