1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Add documentation for using multiple ssh keys on AWS

This commit is contained in:
Sven Pfleiderer 2011-12-02 22:04:31 +01:00
parent dcacefe1ae
commit e64ed47509

View file

@ -61,7 +61,7 @@ Cycling servers is great, but in order to actually ssh in we need to setup ssh k
server = connection.servers.bootstrap(:private_key_path => '~/.ssh/id_rsa', :public_key_path => '~/.ssh/id_rsa.pub', :username => 'ubuntu')
Bootstrap will create the server, but it will also make sure that port 22 is open for traffic and has ssh keys setup. In order to hook everything up it will need the server to be running, so by the time it finishes it will be ready. You can then make commands to it directly:
Bootstrap will create the server, but it will also make sure that port 22 is open for traffic and has ssh keys setup. The ssh key pair you specified will be registered under the name "fog_default" unless you've set `Fog.credential` to a custom string value. In order to hook everything up it will need the server to be running, so by the time it finishes it will be ready. You can then make commands to it directly:
server.ssh('pwd')
server.ssh(['pwd', 'whoami'])
@ -70,6 +70,20 @@ These return an array of results, where each has stdout, stderr and status value
server.destroy
### Managing multiple ssh key pairs
The key pair you've specified, will be registered as "fog_default" after running `bootstrap` for the first time. If you want to use multiple key pairs with the same AWS credentials, you need to set `Fog.credential` to register your other key pairs under different names. Your additional key pair will then be registered as "fog_#{Fog.credential}":
Fog.credential = 'my_custom_key'
connection.servers.bootstrap(:private_key_path => '~/.ssh/my_custom_key', :public_key_path => '~/.ssh/my_custom_key.pub')
If you've already registered a custom key pair e.g. using `connection.create_key_pair` or `connection.import_key_pair`, you can set your key paths using `Fog.credentials` and pass in the name of this key so `bootstrap` will use it instead of "fog_default":
Fog.credentials = Fog.credentials.merge({ :private_key_path => "~/.ssh/my_custom_key", :public_key_path => "~/.ssh/my_custom_key.pub" })
connection.import_key_pair('my_custom_key', IO.read('~/.ssh/my_custom_key.pub')) if connection.key_pairs.get('my_custom_key').nil?
server = connection.servers.bootstrap(:key_name => 'my_custom_key')
## Rackspace Cloud Servers
Rackspace has <a href="http://www.rackspacecloud.com/cloud_hosting_products/servers">Cloud Servers</a> and you can sign up <a href="https://www.rackspacecloud.com/signup">here</a> and get your credentials <a href="https://manage.rackspacecloud.com/APIAccess.do">here</a>.