[PYTHON] How to log in automatically like 1Password from the CLI

Introduction

There is a Mac app called 1Password.

This app assists with strong encryption and automatic login of stored passwords.

Here, I think that many CLI users are using the OSS tool called Keepass.

I also use Keepass.

Therefore, I tried to make a tool to assist automatic login using the database file created by Keepass.

airkeepass

airkeepass

Install and run

git clone https://github.com/syui/airkeepass

cd !$:t

./airkeepass

There are some tools I need, but I've made sure they are automatically downloaded.

The following tools are automatically downloaded. The download location is ʻairkeepass / tool / `.

percol https://github.com/mooz/percol

kptool https://github.com/shirou/kptool

Execution from command

If you do not use the selection menu, check ʻairkeepass / text / theme.txt`.

command Contents
./airkeepass login-a Executing auto login
./airkeepass login-k Add database file
./airkeepass login-l View list
./airkeepass login-t Test login
./airkeepass login-b Browser specification
./airkeepass login-d Delete personal files
./airkeepass login-e End

Automatic login

Let's try automatic login.

A database file for the test is available, so select it. text / keepass-test.kdb

The specified browser opened, successfully entered the ID and password, and pressed Enter.

The location of the database file is saved in text / keepass.txt, so once you run ʻairkeepass`, it will select the same file again.

To change it, select login-k or specify it as an argument.

If you are in a location that does not come up as a candidate, enter the path manually.

important point

You can be sure to log in using Google Chrome.

However, if you select Safari and Firefox, it may fail depending on your browser reload.

The cause is the following code.

script/browser_form_input.sh


Safari|Firefox)

echo "
tell application \"$brows\"

--Key operation(C-v,Tab,input,Enter)
--abridgement

"|osascript -
;;

Google Chrome|*)

echo "
tell application \"$brows\"

--Processing to wait for reload completion
   repeat while loading of active tab of window 1
        delay 0.1
   end repeat

--Run paste
    paste selection active tab of window 1

--Key operation(Tab,input,Enter)
--abridgement

"|osascript -
;;

Chrome writes reload completion and paste processing, but Safari and Firefox do not.

Recommended Posts

How to log in automatically like 1Password from the CLI
How to log in to Docker + NGINX
How to log in to AtCoder with Python and submit automatically
Automatically acquire the operation log in the terminal when logging in to Linux
How to convert csv to tsv in CLI
How to operate Linux from the console
How to access the Datastore from the outside
How to check local GAE from iPhone browser in the same LAN
How to use the C library in Python
Log in to the remote server with SSH
How to get results from id in Celery
How to operate Linux from the outside Procedure
How to measure line speed from the terminal
How to get the files in the [Python] folder
Use pygogo to get the log in json.
The first step to log analysis (how to format and put log data in Pandas)
[Python] How to remove duplicate values from the list
How to get the variable name itself in python
How to run the Ansible module added in Ansible Tower
How to get the number of digits in Python
How to know the current directory in Python in Blender
Send log data from the server to Splunk Cloud
How to allow nologin users to log in on Linux
How to use the exists clause in Django's queryset
How to make an interactive CLI tool in Golang
How to instantly launch Jupyter Notebook from the terminal
How to download files from Selenium in Python in Chrome
[Simple procedure] To log in to ssh without a password
How to change static directory from default in Flask
How to read the CBC (Pulp, python-mip) solver log
How to use the model learned in Lobe in Python
How to post a ticket from the Shogun API
[Python] How to output the list values in order
How to write custom validations in the Django REST Framework
[python] How to check if the Key exists in the dictionary
How to slice a block multiple array from a multiple array in Python
How to debug the Python standard library in Visual Studio
How to use the generator
How to use the __call__ method in a Python class
How to import a file anywhere you like in Python
How to set the html class attribute in Django's forms.py
How to manipulate the DOM in an iframe with Selenium
How to quickly count the frequency of appearance of characters from a character string in Python?
How to generate a query using the IN operator in Django
How to do the initial setup from Django project creation
How to run the Export function of GCP Datastore automatically
How to sample from any probability density function in Python
How to get the last (last) value in a list in Python
How to get all the keys and values in the dictionary
How to hit NAPALM from the Web (NetDevOpsSec reality solution)
[Django] I want to log in automatically after new registration
I can't log in to the admin page with Django3
In Django, how to abbreviate the long displayed string as ....
How to develop in Python
Notes on how to use marshmallow in the schema library
How to plot the distribution of bacterial composition from Qiime2 analysis data in a box plot
[Shell] How to get the remote default branch in Git
How to use the decorator
How to increase the axis
How to start the program
How to take a screenshot of the Chrome screen (prevent it from cutting off in the middle)