I was wondering since some times how I could authenticate on MOS using CLI. Now I got my answer: By reversing the whole SSO auth process in a python script that generate a cookies.txt file, usable with wget.
I know that a simpler method exists using directly wget, but as it doesn't work with every MOS page, I'll prefer a more generic way of doing things.
Here is a quick how to use:
- Edit MOSLogin.py and setup variables inside.
- Install python dependencies (linux/debian):
apt-get install python-pip pip install BeautifulSoup pip install requests
- Run the script
$ ./login.py [-] Initialization...done [-] Gathering JSESSIONID..done [-] Trying loginSuccess.jsp...done [-] Signing in...done [-] Trying to submit credentials...done [-] Checking that credentials are valid...done [-] Logged-in.
- Use the cookies.txt with wget
wget --load-cookies=/tmp/cookies.txt --save-cookies=/tmp/cookies.txt --no-check-certificate http://MOSURL
With a little bit of time and fun, you can imagine every tool based on this to ease your sysadmin life. You can even fetch your SR summary/updates using this cookie...
Get the MOSLogin.py file...