github.com/hashicorp/packer@v1.14.3/website/content/docs/communicators/ssh.mdx (about)

     1  ---
     2  description: |
     3    The `ssh` communicator establishes an SSH connection so that Packer can perform actions, such as upload files and execute scripts, on the machine it creates. 
     4  page_title: Establish an SSH connection
     5  ---
     6  
     7  # Establish an SSH Connection
     8  
     9  This topic describes how to use the `ssh` communicator to establish an SSH connection to the machine it creates so that Packer can perform actions, such as upload files and execute scripts. 
    10  
    11  ## Introduction
    12  
    13  Communicators are the mechanism Packer uses to upload files, execute scripts,
    14  etc. on the machine being created, and are configured within the
    15  [builder](/packer/docs/templates/legacy_json_templates/builders) section.
    16  
    17  The `ssh` communicator does this by using the SSH protocol. It is the default
    18  communicator for a majority of builders.
    19  
    20  If you have an SSH agent configured on the host running Packer, and SSH agent
    21  authentication is enabled in the communicator config, Packer will automatically
    22  forward the SSH agent to the remote host.
    23  
    24  ## Getting Ready to Use the `ssh` Communicator
    25  
    26  The `ssh` communicator is the default communicator for a majority of builders, but
    27  depending on your builder it may not work "out of the box".
    28  
    29  If you are building from a cloud image (for example, building on Amazon), there
    30  is a good chance that your cloud provider has already preconfigured SSH on the
    31  image for you, meaning that all you have to do is configure the communicator in
    32  the Packer template.
    33  
    34  However, if you are building from a brand-new and unconfigured operating system
    35  image, you will almost always have to perform some extra work to configure SSH
    36  on the guest machine. For most operating system distributions, this work will
    37  be performed by a [boot command](/packer/plugins/builders/vmware/iso#boot-configuration)
    38  that references a file which provides answers to the normally-interactive
    39  questions you get asked when installing an operating system. The name of this
    40  file varies by operating system; some common examples are the "preseed" file
    41  required by Debian, the "kickstart" file required by CentOS or the
    42  "answer file", also known as the Autounattend.xml file, required by Windows.
    43  For simplicity's sake, we'll refer to this file as the "preseed" file in the
    44  rest of the documentation.
    45  
    46  If you are unfamiliar with how to use a preseed file for automatic
    47  bootstrapping of an image, please either take a look at our
    48  [quick guides](/packer/guides/automatic-operating-system-installs) to
    49  image bootstrapping, or research automatic configuration for your specific
    50  guest operating system. Knowing how to automatically initalize your operating
    51  system is critical for being able to successfully use Packer.
    52  
    53  ## `ssh` Communicator Reference
    54  
    55  The `ssh` communicator connects to the host via SSH. If you have an SSH agent
    56  configured on the host running Packer, and SSH agent authentication is enabled
    57  in the communicator config, Packer will automatically forward the SSH agent to
    58  the remote host.
    59  
    60  The `ssh` communicator has the following options:
    61  
    62  @include "packer-plugin-sdk/communicator/SSH-not-required.mdx"
    63  
    64  @include "packer-plugin-sdk/communicator/SSH-Key-Pair-Name-not-required.mdx"
    65  
    66  @include "packer-plugin-sdk/communicator/SSH-Agent-Auth-not-required.mdx"
    67  
    68  @include "packer-plugin-sdk/communicator/SSH-Temporary-Key-Pair-not-required.mdx"
    69  
    70  @include "packer-plugin-sdk/communicator/SSH-Private-Key-File-not-required.mdx"
    71  
    72  ~> Note: The options `ssh_keypair_name`, `ssh_agent_auth`,
    73  `temporary_key_pair_name`, and `ssh_private_key_file` are supported by the
    74  communicator; however, they may not be supported for every builder. Please refer
    75  to the builder documentation for supported options.
    76  
    77  ### `ssh` Communicator Details
    78  
    79  Packer will only use one authentication method, either `publickey` or if
    80  `ssh_password` is used Packer will offer `password` and `keyboard-interactive`
    81  both sending the password. In other words Packer will not work with _sshd_
    82  configured with more than one configured authentication method using
    83  `AuthenticationMethods`.
    84  
    85  Packer supports the following MACs:
    86  
    87  - hmac-sha1
    88  - hmac-sha1-96
    89  - hmac-sha2-256
    90  - `hmac-sha2-256-etm@openssh.com`
    91  
    92  For more information on the ciphers that Packer supports, check the docs for
    93  the [ssh_ciphers](/packer/docs/communicators/ssh#ssh_ciphers) template option.