Problem
How to create a new cloud server and automatically deploy ssh authorized_keys file with our public ssh key.
Solution description with demonstration
- Generate a new pub and private key pair that your are going to be using with key authentication for all new cloud servers
- Rename and save your keys so you don't override them (keep the private key secure of course!)
- Create a new cloud server (cs) with your public key saved automatically in authorized_keys file
- Login to cs using your private key
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ssh-keygen | |
Generating public/private rsa key pair. | |
Enter file in which to save the key (/root/.ssh/id_rsa): | |
$ cd .ssh | |
mv id_rsa.pub id_rsa_auxiliary.pub | |
mv id_rsa id_rsa_auxiliary | |
# http://rtomaszewski.blogspot.co.uk/2013/10/home-directory-and-dotfiles-management.html | |
# https://github.com/rtomaszewski/dotfiles/blob/master/.bashrc_rado_aux | |
$ ls -la $MY_AUX_SSH_KEY_PRIV $MY_AUX_SSH_KEY_PUB | |
$ auxnova --image 80fbcb55-b206-41f9-9bc2-2dd7aac6c061 --flavor 2 test-cs | |
+------------------------+--------------------------------------+ | |
| Property | Value | | |
+------------------------+--------------------------------------+ | |
| status | BUILD | | |
| updated | 2013-12-09T00:18:59Z | | |
| OS-EXT-STS:task_state | scheduling | | |
| key_name | None | | |
| image | Ubuntu 12.04 LTS (Precise Pangolin) | | |
| hostId | | | |
| OS-EXT-STS:vm_state | building | | |
| flavor | 512MB Standard Instance | | |
| id | b51663b5-eaa0-4e66-9161-48b28d133d63 | | |
| user_id | 10016865 | | |
| name | test-cs | | |
| adminPass | XXX | | |
| tenant_id | 10016214 | | |
| created | 2013-12-09T00:18:59Z | | |
| OS-DCF:diskConfig | AUTO | | |
| accessIPv4 | | | |
| accessIPv6 | | | |
| progress | 0 | | |
| OS-EXT-STS:power_state | 0 | | |
| config_drive | | | |
| metadata | {} | | |
+------------------------+--------------------------------------+ | |
$ nova show test-cs | grep network | |
$ auxssh IP | |
http://developer.rackspace.com/blog/step-by-step-walkthrough-to-using-chef-to-bootstrap-windows-nodes-on-the-rackspace-cloud.html
No comments:
Post a Comment