Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jesseemond/ssh-keys-generator
RSA SSH keys generator for educational purposes.
https://github.com/jesseemond/ssh-keys-generator
Last synced: about 17 hours ago
JSON representation
RSA SSH keys generator for educational purposes.
- Host: GitHub
- URL: https://github.com/jesseemond/ssh-keys-generator
- Owner: JesseEmond
- Created: 2015-08-30T06:44:53.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-10-17T00:04:10.000Z (about 9 years ago)
- Last Synced: 2024-10-12T20:36:33.695Z (about 1 month ago)
- Language: Python
- Size: 199 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SSH RSA key-pair generation
Generates an SSH RSA key-pair for **educational purposes** only.*This originated from a friend offering to create a user for me on his server and
asking for generated SSH keys. I was working on an assignment related to
Miller-Rabin at the time and jokingly said that I would make the generator
myself. A couple of classes and late hours later, here it is.*Do not use in any serious context. Feel free to open issues or pull requests
if you want to improve this as a learning resource.## Usage
```
> ./gen-ssh-keys.py --help
$ usage: gen-ssh-keys.py [-h] [--out OUTPUT-FILE] [--bits BITS] [--verbose]
$ [--comment COMMENT]
$
$ Generate an SSH RSA key pair.
$
$ optional arguments:
$ -h, --help show this help message and exit
$ --out OUTPUT-FILE, -o output-file
$ File prefix for the key generated (output-file and
$ output-file.pub)
$ --bits BITS, -b BITS Length (in bits) of the key generated
$ --verbose, -v If the current state should be printed as the keys are
$ generated.
$ --comment COMMENT, -c COMMENT
$ Comment to put in the public key file generated.
```**Note**: assumes that you are using Python 3.
## Example
**Note**: can take multiple (>10-15) minutes to run with a relatively high amount
of bits for the prime numbers (e.g. 4096).
```
> ./gen-ssh-keys.py --verbose
$ Generating p...
$ Generating q...
$ Calculating RSA parameters...
$ Outputing private key to file...
$ Private key saved to: id_rsa
$ Outputing public key to file...
$ Public key saved to: id_rsa.pub
$ Done!
``````
> cat id_rsa.pub
$ ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAEAQCIqB+ ... gYInDMtwHet4vwOmMublq9RxCCgK1FVkMmtvQeYq8JTywDcg2XbUF04wrCHXr
``````
> cat id_rsa
$ -----BEGIN RSA PRIVATE KEY-----
$ MIISJwIBAAKCBAEAiKgfrZnsSRXfY1SIdvB+ ... OAj4ktw1PPIzxx9sWgNL5DUbYBqMbdeuVf47iTEFNVT3ac2NfEltpQ==
$ -----END RSA PRIVATE KEY-----
```We may then test that our generated files make sense using `ssh-keygen`:
```
> diff <(ssh-keygen -y -f id_rsa) id_rsa.pub
$ (no diff)
```## Setup
Run `./setup` to download the required dependencies (might need `sudo`).**Note**: assumes that you have
[`pip`](https://pypi.python.org/pypi/pip) available.## Running Unit Tests
Use `./run-tests` to execute the unit tests (conveniently does
`python -m unittest discover` for you).## Documentation
For additional documentation on Miller-Rabin, see this other repository
related to primality testing:
[benchmarkus-prime](https://github.com/JesseEmond/benchmarkus-prime).### todo
- [x] Primality testing
- [x] Prime generation
- [x] RSA parameters generation
- [x] RSA public key format output
- [x] RSA private key format output
- [ ] Test with OpenSSH