{"_id":"578bcf98e1c6c90e000b54da","version":{"_id":"573ed4bea233380e005db14d","__v":2,"project":"56b86cc286d2b0190070bcda","createdAt":"2016-05-20T09:11:26.847Z","releaseDate":"2016-05-20T09:11:26.847Z","categories":["573ed4bea233380e005db14e","573ed4bea233380e005db14f","573ed4bea233380e005db150","578bcf36bb7d810e00e01c05"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"master","version_clean":"0.3.0-0.4","version":"0.3-0.4"},"project":"56b86cc286d2b0190070bcda","category":{"_id":"578bcf36bb7d810e00e01c05","project":"56b86cc286d2b0190070bcda","version":"573ed4bea233380e005db14d","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-07-17T18:32:22.011Z","from_sync":false,"order":2,"slug":"connection-adapters","title":"Connection adapters"},"githubsync":"","user":"56b86c990094520d006b3c33","parentDoc":null,"__v":0,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-07-17T18:34:00.184Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"settings":"","results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":1,"body":"The SSH connection adapter provides support for connecting and deploying to a host through the SSH protocol.\n\n## Connection options\n| Name                      | Type   | Default value        | Description                                                   |\n|---------------------------|--------|----------------------|---------------------------------------------------------------|\n| authenticationType        | string | publickey            | The type of authentication with the server. Possible values are: password, publickey and agent. |\n| authenticationUsername    | string | The current username | The username to connect to the remote host.                                                     |\n| authenticationCredentials | string |                      | The credentials required to connect to the remote host. This option expects a different value depending on 'authenticationType'. See the explained options below. |\n\n\n## Configuring the connection adapter\nThe SSHConnectionAdapter has three different types of authenticating with a remote host.\nThe following examples show the different types and how to configure them.\n\n\n### Public key authentication\nPublic/private key authentication is the default authentication type.\nWithout the `connectionOptions` key set it will by default try to authenticate using the private key located at `~/.ssh/id_rsa`.\n\nWhen your private key has a different name, it can be configured by defining it's location in `authenticationCredentials`:\n\n``` json\n{\n    \"$extend\": \"accompli://recipe/defaults.json\",\n    \"hosts\": [\n        {\n            \"stage\": \"test\",\n            \"connectionType\": \"ssh\",\n            \"hostname\": \"example.com\",\n            \"path\": \"/var/www/example.com\",\n            \"connectionOptions\": {\n                \"authenticationType\": \"publickey\",\n                \"authenticationCredentials\": \"~/.ssh/another_id_rsa\"\n            }\n        }\n    ]\n}\n```\n\nOptionally, you can authenticate with a different username by configuring `authenticationUsername`.\n\n\n### Username and password\nWith username and password authentication you configure the password in the `authenticationCredentials` key:\n\n``` json\n{\n    \"$extend\": \"accompli://recipe/defaults.json\",\n    \"hosts\": [\n        {\n            \"stage\": \"test\",\n            \"connectionType\": \"ssh\",\n            \"hostname\": \"example.com\",\n            \"path\": \"/var/www/example.com\",\n            \"connectionOptions\": {\n                \"authenticationType\": \"password\",\n                \"authenticationUsername\": \"anotheruser\",\n                \"authenticationCredentials\": \"mySecretPassword\"\n            }\n        }\n    ]\n}\n```\n\nPlease note that this method is considered unsafe as you're exposing your password inside the Accompli configuration.\nIn an upcoming version of Accompli you will be able to store credentials inside a credentials store.\n\n\n### Local SSH agent\nBesides the public/private key authentication, you can also authenticate using public/private keys through a local SSH agent.\n\nTo use a local SSH agent you configure 'agent' within the `authenticationType` key:\n``` json\n{\n    \"$extend\": \"accompli://recipe/defaults.json\",\n    \"hosts\": [\n        {\n            \"stage\": \"test\",\n            \"connectionType\": \"ssh\",\n            \"hostname\": \"example.com\",\n            \"path\": \"/var/www/example.com\",\n            \"connectionOptions\": {\n                \"authenticationType\": \"agent\"\n            }\n        }\n    ]\n}\n```\n\n#### Initializing a local SSH agent\nTo initialize a local SSH agent you need to execute the following command:\n```\n$ eval $(ssh-agent)\n```\n\nThis will start a SSH agent daemon and create the environment variables required by Accompli (and other programs) to detect and use the agent.\n\nAdding SSH keys to the SSH agent is done by executing:\n```\n$ ssh-add <location-of-ssh-key>\n```","excerpt":"","slug":"sshconnectionadapter","type":"basic","title":"SSHConnectionAdapter"}

SSHConnectionAdapter


The SSH connection adapter provides support for connecting and deploying to a host through the SSH protocol. ## Connection options | Name | Type | Default value | Description | |---------------------------|--------|----------------------|---------------------------------------------------------------| | authenticationType | string | publickey | The type of authentication with the server. Possible values are: password, publickey and agent. | | authenticationUsername | string | The current username | The username to connect to the remote host. | | authenticationCredentials | string | | The credentials required to connect to the remote host. This option expects a different value depending on 'authenticationType'. See the explained options below. | ## Configuring the connection adapter The SSHConnectionAdapter has three different types of authenticating with a remote host. The following examples show the different types and how to configure them. ### Public key authentication Public/private key authentication is the default authentication type. Without the `connectionOptions` key set it will by default try to authenticate using the private key located at `~/.ssh/id_rsa`. When your private key has a different name, it can be configured by defining it's location in `authenticationCredentials`: ``` json { "$extend": "accompli://recipe/defaults.json", "hosts": [ { "stage": "test", "connectionType": "ssh", "hostname": "example.com", "path": "/var/www/example.com", "connectionOptions": { "authenticationType": "publickey", "authenticationCredentials": "~/.ssh/another_id_rsa" } } ] } ``` Optionally, you can authenticate with a different username by configuring `authenticationUsername`. ### Username and password With username and password authentication you configure the password in the `authenticationCredentials` key: ``` json { "$extend": "accompli://recipe/defaults.json", "hosts": [ { "stage": "test", "connectionType": "ssh", "hostname": "example.com", "path": "/var/www/example.com", "connectionOptions": { "authenticationType": "password", "authenticationUsername": "anotheruser", "authenticationCredentials": "mySecretPassword" } } ] } ``` Please note that this method is considered unsafe as you're exposing your password inside the Accompli configuration. In an upcoming version of Accompli you will be able to store credentials inside a credentials store. ### Local SSH agent Besides the public/private key authentication, you can also authenticate using public/private keys through a local SSH agent. To use a local SSH agent you configure 'agent' within the `authenticationType` key: ``` json { "$extend": "accompli://recipe/defaults.json", "hosts": [ { "stage": "test", "connectionType": "ssh", "hostname": "example.com", "path": "/var/www/example.com", "connectionOptions": { "authenticationType": "agent" } } ] } ``` #### Initializing a local SSH agent To initialize a local SSH agent you need to execute the following command: ``` $ eval $(ssh-agent) ``` This will start a SSH agent daemon and create the environment variables required by Accompli (and other programs) to detect and use the agent. Adding SSH keys to the SSH agent is done by executing: ``` $ ssh-add <location-of-ssh-key> ```