This article is for you if you’re working with different clients and you have hard time remembering which ssh command you use to access a certain server. That was always a frustrating thing for me because there are different servers with different secret keys. I get confused all the time so I created myssh.
myssh is a simple tool that wraps all your remote machines’ server credentials in one place, so you can list, save, and connect to any remote machine that’s saved. The tool is in it’s early stages, so you’re all welcome to contribute.
Terms Learned :
- Python Packaging
- Database Change Management
Obstacles through the journey :
- Pointing to directories dynamically in ini files – the solution is to set the migration settings in the runtime of the program, which required me to use alembic config API.
- Executing commands after installing the package to initiate the database – solved by updating the package manger and building a wrapper class for installation.
Tools helped me :
Let’s Use it !!
- Python => 3.6
- virtualenv –
sudo -H pip install virtualenv
First we create our own virtualenv.
ahmmkh@mypc:~$ virtualenv myssh -p python3
After successfully creating the virtual environment our terminal will look something like this:
That’s totally awesome and now we can install our tool:
(myssh) ahmmkh@mypc:~$ pip install myssh
After successfully installing the package now you will be exposed to two commands:
sshentry – (save command )
This command will save the ssh server info into a local database in your machine so you can use it later to connect to it.
usage: sshentry [-h] [--host HOST] [--key_path KEY_PATH] [--user USER] name positional arguments: name name you want to provide for server optional arguments: -h, --help show this help message and exit --host HOST, -s HOST name of host --key_path KEY_PATH, -i KEY_PATH path of key --user USER, -u USER name of user
con – (connection command)
this command will connect you to your saved server
usage: con [-h] name positional arguments: name name of server optional arguments: -h, --help show this help message and exit
(myssh) ahmmkh@mypc:~$ sshentry myserver --host 184.108.40.206 -i /home/ahmmkh/key.pem --user ubuntu
Then after that you can connect to your server simply by typing:
(myssh) ahmmkh@mypc:~$ con myserver
And there you go! You will access the terminal of your remote machine and start working right away!
To contribute this the github repo:
Time Taken: It took a total of about 9 hours to complete the above project.