From cb0ad5367d41df20cd479e5248206c30bbdc8643 Mon Sep 17 00:00:00 2001 From: Brendan McDevitt Date: Mon, 1 Jan 2018 20:46:46 -0500 Subject: [PATCH] added python snippet of ssh key --- ...-01-01-100-days-of-code-challenge.markdown | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/_posts/2018-01-01-100-days-of-code-challenge.markdown b/_posts/2018-01-01-100-days-of-code-challenge.markdown index 20a533b..5851964 100644 --- a/_posts/2018-01-01-100-days-of-code-challenge.markdown +++ b/_posts/2018-01-01-100-days-of-code-challenge.markdown @@ -10,3 +10,23 @@ my new year with something I have just come across: [100daysofcode](http://100da I have forked the 100 days of code repo from github and am using the log to track my daily progress. It will be fun, and it will be a great way to keep me accountable for building my python knowledge. + +Day 1: +```python +def gen_ssh_keypair(): + """ Generate an RSA private / public keypair """ + key = RSA.generate(2048) + + # generate private key - output to file + with open('rsa_privkey.pem', 'wb') as privkey: + privkey.write(key.exportKey()) + + # generate public key - output to file + with open('rsa_pubkey.pem', 'wb') as pubkey: + pubkey.write(key.publickey().exportKey()) + + return 0 + + +gen_ssh_keypair() +```