- setup the python portion
- maybe also get it setup to use specific password files
- Consider using environment variables or a secure keyring service like
passorgopass
- Consider using environment variables or a secure keyring service like
This project is an attempt at trying to get a python textual front end connecting to a backend bash script as a way of connecting to various servers using ssh.
The bash portion is to do the following:
- The script dynamically constructs the ssh command based on the input parameters and the JSON configuration.
- It retrieves the user, domain, and machine_name from the JSON file.
- The display_help function shows a list of valid machine types and domains in a tabular format using column -t. This makes it easy to understand the available options.
- The
basescript checks if the providedmachine_typeanddomainexist in the JSON configuration. If not, it displays an error message and the help text.
-
Create a
.jsonfile to match what your case is (also visible inexample.json)-
Example:
{ "user": "user", "domains": { "east": "us-east.com", "west": "us-west.com" }, "machines": { "db1": "test-db1", "db2": "test-db2", "ui": "test-ui", "server": "test-server" } }
-
-
Also create a
.envfile that will store your password (if needed)PASSWORD=mypassword
-
Adding New Machines/domains:
- To add new machine types or domains, simply update the machines.json file.
-
Support for Different Users:
- You can extend create new
jsonfiles with different users as needed.
- You can extend create new
-
Make sure the scripts are executable:
chmod +x connect_base.sh chmod +x connect_plain.sh chmod +x connect_pass.sh
-
Run the script with parameters:
./connect db east ./connect_pass db east
This will connect to
ssh user@test-db1.us-east.comand print the password for manual entry. -
Run the script without parameters to see the help text:
./connect ./connect_pass
This will display a list of available machine types and domains.
The python portion is a script making use of the textual library to make a clickable user interface in the terminal that can be used to select the machine and domain rather than typing.
- would be really neat if it even came with the option to add to the file from the interface
- also would be nice for "one off connections" that allow user input
- even cooler if it kept a history of these "one offs" in a separate db-esq file
Once all of this is setup, it would be good to make aliases that could be used to call these from anywhere
Add the following lines into your .bashrc (or where ever you prefer to stick your aliases)
connect=~/git/textual-servers/bash/connect_plain.sh
connect-pass=~/git/textual-servers/bash/connect_pass.shAdd the following lines into your .bashrc (or where ever you prefer to stick your aliases)
connect=~/git/textual-servers/bash/connect.py