ssh – Jay R. Wren – lazy dawg evarlast http://jrwren.wrenfam.com/blog babblings of a computer loving fool Wed, 15 Feb 2017 02:57:57 +0000 en-US hourly 1 https://wordpress.org/?v=4.7.2 Getting a Windows Password for EC2 Instance http://jrwren.wrenfam.com/blog/2014/06/23/getting-a-windows-password-for-ec2-instance/ Tue, 24 Jun 2014 03:07:27 +0000 http://jrwren.wrenfam.com/blog/?p=1121 Continue reading "Getting a Windows Password for EC2 Instance"]]> … without pasting your private key to ec2.

EC2 should never see your private key… because.. security!

I launched a Windows Server 2012 R2 instance in EC2 recently and while the AWS console does let you retrieve an Administrator password, it requires you to paste your PRIVATE key to AWS console to do it. I couldn’t bring myself to do it, so I learned how to use boto to get the encrypted password data and openssl cmdline to decrypt it to get the password.

Its a 2 step process with maybe the zeroth step being writing a .boto file with your aws credentials if you have never used boto.

import boto
import base64
ec2 = boto.connect_ec2()
inst = ec2.get_all_instances()[0].instance
data = ec2.get_password_data(inst.id)
open(‘ec2-admin-password’,’w’,write(base64.decodestring(data))

I’m assuming its the only instance running. If you have lots of others, use a list comprehension with if clause to filter to one on the get_all_instances() call, or just skip that call and paste an id string you see in AWS console for inst.id in the get_password_data call.

openssl rsautil -in ec2-admin-password -inkey .ssh/id_rsa -decrypt

You’ll be prompted for your private key password (and you MUST have a password. ssh-agent is easy) and then the Administrator password will be output to stdout.

 

]]>
Converting your existing ssh rsa key for use with Windows Azure http://jrwren.wrenfam.com/blog/2013/09/22/converting-your-existing-ssh-rsa-key-for-use-with-windows-azure/ http://jrwren.wrenfam.com/blog/2013/09/22/converting-your-existing-ssh-rsa-key-for-use-with-windows-azure/#comments Mon, 23 Sep 2013 02:06:24 +0000 http://jrwren.wrenfam.com/blog/?p=1094 Continue reading "Converting your existing ssh rsa key for use with Windows Azure"]]> Oh Microsoft, it seems like you make simple things complex.

I could not find anything on converting an existing ssh key for use with Azure. Once I figured out what was needed and the commands available to me, it was easy. It only took me hours of fiddling with ssh-keygen and openssl.

The magic was learning that openssh stores its id_rsa in a format which openssl can read. This means I can use openssl directly to convert this private key.

openssl req -x509 -new -days 365 -key id_rsa -out id_rsa.x509req.pem

Type in your password for your private key (if you are not using a password, you should be.) Then fill out the certificate request fields.

Now you can boot your azure vm using id_rsa.x509req.pem

azure vm create jrwtest b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu-12_04_3-LTS-amd64-server-20130916.1-en-us-30GB jwren –location “East US” -e -t id_rsa.x509req.pem

Now you can secure shell to your azure vm.

ssh jrwtest.cloudapp.net

SWEET. 🙂  No generating new ssh keys for me.

]]>
http://jrwren.wrenfam.com/blog/2013/09/22/converting-your-existing-ssh-rsa-key-for-use-with-windows-azure/feed/ 2