SSH Key based authentication setup using ansible. In this post, we are going to see how to enable the SSH key-based authentication between two remote servers using ansible by creating and exchanging the keys. We are going to use ansible built-in modules like Shell and Copy and Fetch and most importantly authorizedkey.
The below requirements are needed on the host that executes this module.
Parameter | Choices/Defaults | Comments |
---|---|---|
aws_access_key string | AWS access key. If not set then the value of the AWS_ACCESS_KEY_ID, AWS_ACCESS_KEY or EC2_ACCESS_KEY environment variable is used. | |
aws_secret_key | AWS secret key. If not set then the value of the AWS_SECRET_ACCESS_KEY, AWS_SECRET_KEY, or EC2_SECRET_KEY environment variable is used. | |
debug_botocore_endpoint_logs added in 2.8 |
| Use a botocore.endpoint logger to parse the unique (rather than total) 'resource:action' API calls made during a task, outputing the set to the resource_actions key in the task results. Use the aws_resource_action callback to output to total list made during a playbook. The ANSIBLE_DEBUG_BOTOCORE_LOGS environment variable may also be used. |
ec2_url string | Url to use to connect to EC2 or your Eucalyptus cloud (by default the module will use EC2 endpoints). Ignored for modules where region is required. Must be specified for all other modules if region is not used. If not set then the value of the EC2_URL environment variable, if any, is used. | |
force boolean |
| Force overwrite of already existing key pair if key has changed. |
key_material - | ||
name | Name of the key pair. | |
profile string | Uses a boto profile. Only works with boto >= 2.24.0. | |
region string | The AWS region to use. If not specified then the value of the AWS_REGION or EC2_REGION environment variable, if any, is used. See http://docs.aws.amazon.com/general/latest/gr/rande.html#ec2_region | |
security_token | AWS STS security token. If not set then the value of the AWS_SECURITY_TOKEN or EC2_SECURITY_TOKEN environment variable is used. | |
state |
| |
validate_certs |
| When set to 'no', SSL certificates will not be validated for boto versions >= 2.6.0. |
wait boolean |
| Wait for the specified action to complete before returning. This option has no effect since version 2.5. |
wait_timeout - | Default: | How long before wait gives up, in seconds. This option has no effect since version 2.5. |
Note
AWS_URL
or EC2_URL
, AWS_ACCESS_KEY_ID
or AWS_ACCESS_KEY
or EC2_ACCESS_KEY
, AWS_SECRET_ACCESS_KEY
or AWS_SECRET_KEY
or EC2_SECRET_KEY
, AWS_SECURITY_TOKEN
or EC2_SECURITY_TOKEN
, AWS_REGION
or EC2_REGION
AWS_REGION
or EC2_REGION
can be typically be used to specify the AWS region, when required, but this can also be configured in the boto config fileCommon return values are documented here, the following are the fields unique to this module:
Key | Returned | Description | |
---|---|---|---|
changed boolean | always | Sample: | |
key | always | details of the keypair (this is set to null when state is absent) | |
fingerprint string | when state is present | Sample: b0:22:49:61:d9:44:9d:0c:7e:ac:8a:32:93:21:6c:e8:fb:59:62:43 | |
name string | when state is present | Sample: | |
private_key | when a new keypair is created by AWS (key_material is not provided) | private key of a newly created keypair -----BEGIN RSA PRIVATE KEY----- MIIEowIBAAKC.. -----END RSA PRIVATE KEY----- | |
msg string | always | Sample: |
Hint
The initial base of Photoshop’s naming scheme is on the version numbers. For example, the eighth version number of Photoshop was Photoshop CS, and the ninth was Photoshop CS2. Whereas, in October 2002, following the introduction of Creative Suite branding, every new version of Adobe Photoshop Crack has a design with CS plus a number.
If you notice any issues in this documentation, you can edit this document to improve it.
The below requirements are needed on the host that executes this module.
Parameter | Choices/Defaults | Comments |
---|---|---|
account string | ||
api_http_method |
| HTTP method used to query the API endpoint. If not given, the CLOUDSTACK_METHOD env variable is considered.As the last option, the value is taken from the ini config file, also see the notes. |
api_key | API key of the CloudStack API. If not given, the CLOUDSTACK_KEY env variable is considered.As the last option, the value is taken from the ini config file, also see the notes. | |
api_region string | Default: | Name of the ini section in the cloustack.ini file.If not given, the CLOUDSTACK_REGION env variable is considered. |
api_secret string | If not set, the CLOUDSTACK_SECRET env variable is considered.As the last option, the value is taken from the ini config file, also see the notes. | |
api_timeout integer | If not given, the CLOUDSTACK_TIMEOUT env variable is considered.As the last option, the value is taken from the ini config file, also see the notes. | |
api_url | URL of the CloudStack API e.g. https://cloud.example.com/client/api. If not given, the CLOUDSTACK_ENDPOINT env variable is considered.As the last option, the value is taken from the ini config file, also see the notes. | |
domain string | ||
name | Name of public key. | |
project string | Name of the project the public key to be registered in. | |
public_key string | ||
state |
|
Note
cs
library’s configuration method if credentials are not provided by the arguments api_url
, api_key
, api_secret
. Configuration is read from several locations, in the following order. The CLOUDSTACK_ENDPOINT
, CLOUDSTACK_KEY
, CLOUDSTACK_SECRET
and CLOUDSTACK_METHOD
. CLOUDSTACK_TIMEOUT
environment variables. A CLOUDSTACK_CONFIG
environment variable pointing to an .ini
file. A cloudstack.ini
file in the current working directory. A .cloudstack.ini
file in the users home directory. Optionally multiple credentials and endpoints can be specified using ini sections in cloudstack.ini
. Use the argument api_region
to select the section name, default section is cloudstack
. See https://github.com/exoscale/cs for more information.Common return values are documented here, the following are the fields unique to this module:
Key | Returned | Description |
---|---|---|
fingerprint string | success | Sample: |
id | success | UUID of the SSH public key. a6f7a5fc-43f8-11e5-a151-feff819cdc9f |
name string | success | Sample: |
private_key | changed | Private key of generated SSH keypair. -----BEGIN RSA PRIVATE KEY----- MII..8tO -----END RSA PRIVATE KEY----- |
Hint
If you notice any issues in this documentation, you can edit this document to improve it.