contains some of my scripts to start development faster. Since my build and development environment is getting bigger, I wanted to have some reproducible scripts for setting up SSH connections and installing software. In future, I plan to extend this repo with some additional, reusable functions on demand, so I don't have to remind how to do this repeating tasks.
Generates SSH keys on a client PC and deploys them to the build/server PC.
| Flag | Description |
|---|---|
--generate |
Generate a new SSH key of the specified type (rsa, dsa, ecdsa, ed25519) |
--key-path |
Directory where keys are stored/generated (defaults to ~/.ssh) |
--deploy-to-host |
Deploys the public key to <user>@<host> via SSH |
--password_type |
Password input type: prompt or dotenv |
--dotenv-file |
Path to .env file containing PASSWORD=yourpassword |
ssh-keys --generate rsa --key-path ~/.sshIf a key already exists in --key-path, it is detected automatically — no --generate needed:
ssh-keys --deploy-to-host user@host --key-path ~/.sshssh-keys --generate ed25519 --key-path ~/.ssh --deploy-to-host user@hostssh-keys --deploy-to-host user@host --password_type dotenv --dotenv-file /path/to/.envThe .env file requires just one line:
PASSWORD=yourpassword
- Key generation: uses
ssh-keygento create keys in--key-path. - Deployment: uses
paramikoto copy the public key to~/.ssh/authorized_keyson the remote host. - Key detection: when
--deploy-to-hostis used without--generate, the script scans--key-pathfor existing.pubfiles (id_rsa.pub,id_ed25519.pub, etc.) to determine the key type automatically. - Password: prompted interactively by default, or read from a
.envfile when--password_type dotenvis specified.
Tests are implemented in tests/ directory.
To install development dependencies (pytest, python-dotenv etc.):
pip install -e ".[dev]"To run tests:
pytestOr with coverage reporting:
pytest --cov=scripts --cov-report=term-missingTo build the package:
pip install build
python -m buildIf you have any suggestions to improve code/tests, feel free to create a PR for the scripts or write me a message. More specifically:
- I want to test password prompt automatically.
- add a connection check at the end of test_ssh_keys_deployment.