Support: 1-800-961-4454
Sales Chat
1-800-961-2888

Rackspace Cloudvent Calendar Day 2: Automating SSH Keys

1

In the spirit of the holiday season, I’m sharing some tips and features of our cloud that you may not know about. In this countdown I’ll have 24 posts for you, each covering a single topic or feature about Rackspace Cloud products. We’ll post one per day so keep checking back!

Setting up SSH keys to use with your Cloud Servers is easy and makes login a snap. You’re going to need the rackspace-novaclient installed – you can find the instructions here. Be sure you set up your .bash_profile with variables that match your account.

Once you have the client installed, you need to generate a SSH key. This step can be skipped if you already have a key that you want to use. Open up a terminal and issue this command:

ssh-keygen –t rsa

This will generate two files: your public key and your private key. Your private key should NEVER be shared with anyone. NEVER EVER. Not even with us. The terminal will prompt you on where you want to save these files, and for a password. If this is your first SSH key, the default locations are fine. You don’t need a password if you don’t want one – just hit enter to accept the defaults.

So now you have two files: ~/.ssh/id_rsa (Private) and ~/.ssh/id_rsa.pub (Public). Let’s upload your PUBLIC key to your account with the nova client:

nova keypair-add --pub-key ~/.ssh/id_rsa.pub mykey

Congrats! You’ve just added your key to your account. Now you can build a server with that key already in place:

nova boot -–image <UUID> --flavor <FLAVOR> --key-name mykey SERVERNAME

The server will be created and have your public key in your authorized_keys file. Now when you SSH to the server, you won’t be prompted for a password.

Did you miss day 1? You can read it here. Check back tomorrow for day 3!

About the Author

This is a post written and contributed by Hart Hoover.

Hart Hoover is a Cloud Strategist at Rackspace Hosting. Hoover started his career as a Racker in 2007 as a Linux Systems Administrator, providing technical support for dedicated servers. He moved to the cloud in 2009 to help design the Managed Cloud Servers support model. He has presented at various technical conferences, maintains and contributes to the Rackspace DevOps Blog, and advises Rackspace customers on best practices for cloud computing.


More
1 Comment

It might be worth mentioning nova keypair-list here :)

avatar Christian Ashby on March 14, 2014 | Reply

Leave a New Comment

(Required)


Racker Powered
©2014 Rackspace, US Inc.