Answers: <p>First, make sure that packer runs in debug mode (<code>packer build -debug ...</code>), otherwise the temporary key will not be written to disk but will only be kept in memory.</p>
  
  <p>packer will store the key in its working directory. In other words, look in the same directory from which you started the packer process.</p>
  
  <p>If you use AWS, the file will be called <code>ec2_amazon-ebs.pem</code>. Assuming you are building an Ubuntu image, you should be able to login to the instance with this command:</p>
  
  <pre><code>ssh -i ec2_amazon-ebs.pem ubuntu@&lt;ip&gt;
  </code></pre>
  
  <p>(where <code>&lt;ip&gt;</code> can be found in the packer output or through the AWS console)</p>
  
Answers: CC BY-SA 4.0
Answers: 2020-06-18T07:40:04.313Z
Answers: For me, it was `ec2_centos.pem` on packer v1.4.1, obviously, I was building a CentOS VM
Answers: vikas027
Answers: CC BY-SA 4.0
Answers: 2019-07-25T23:34:05.890Z
Answers: 2019-07-25T23:34:05.890Z
Answers: Philipp Claßen
Answers: <p>They are likely in the user's home folder, or the folder in which packer is running.</p>
  
  <p>You can look at <code>~/.ssh</code>, or you can specify you own <a href="https://packer.io/docs/builders/amazon-instance.html" rel="nofollow noreferrer">keypair</a>.</p>
  
Answers: CC BY-SA 4.0
Answers: 2020-09-22T14:00:12.653Z
Answers: It is not.  Packer only emits to file (in local dir) if running in debug.
Answers: Eddie
Answers: CC BY-SA 4.0
Answers: 2019-07-23T09:48:00.247Z
Answers: 2019-07-24T10:19:14.390Z
Answers: 2019-07-24T10:19:14.390Z
Answers: Matthieu Ducorps
Body: <p>I`m creating a new image and everything is working. I would like to debug via ssh during the instance creation. A temp keypair is created and attached to the temp instance. My question is, can I get this keypair somewhere in order to debug it?</p>
  
  <pre><code>==&gt; amazon-ebs: Prevalidating AMI Name...
      amazon-ebs: Found Image ID: ami-0866798422f5d546b
  ==&gt; amazon-ebs: Creating temporary keypair: packer_5cc6c77d-494a-f185-b5b3-f9b59e62fd4e
  </code></pre>
  
  <p>Best,</p>
  
  <p>Armando</p>
  
Comments: CC BY-SA 4.0
Comments: 2019-07-25T07:07:27.970Z
Comments: This question has intrigued me quite a bit, so I went digging into the packer source code. It seems, as Mattieu wrote below, that the key is only written if you run in debug mode, or of course use your own. Else, it is kept in memory. (I only looked at the EBS builder)
Comments: Bruce Becker
Tags: <packer>
Title: Is it possible to locate the temp keypair generated by Packer?
UserDisplayName: armandomiani
ThreadText: # Is it possible to locate the temp keypair generated by Packer?
  
  (Asked by: username_0 on 2019-04-29)
  
  I`m creating a new image and everything is working. I would like to debug via ssh during the instance creation. A temp keypair is created and attached to the temp instance. My question is, can I get this keypair somewhere in order to debug it?
  
  ```
  ==> amazon-ebs: Prevalidating AMI Name...
      amazon-ebs: Found Image ID: ami-0866798422f5d546b
  ==> amazon-ebs: Creating temporary keypair: packer_5cc6c77d-494a-f185-b5b3-f9b59e62fd4e
  
  ```
  
  Best,
  
  Armando
  
  **Tags:** packer
  
  > **Comments:**
  > **username_1**: This question has intrigued me quite a bit, so I went digging into the packer source code. It seems, as Mattieu wrote below, that the key is only written if you run in debug mode, or of course use your own. Else, it is kept in memory. (I only looked at the EBS builder)  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2019-07-25. Score: 10
  
  First, make sure that packer runs in debug mode (`packer build -debug ...`), otherwise the temporary key will not be written to disk but will only be kept in memory.
  
  packer will store the key in its working directory. In other words, look in the same directory from which you started the packer process.
  
  If you use AWS, the file will be called `ec2_amazon-ebs.pem`. Assuming you are building an Ubuntu image, you should be able to login to the instance with this command:
  
  ```
  ssh -i ec2_amazon-ebs.pem ubuntu@<ip>
  
  ```
  
  (where `<ip>` can be found in the packer output or through the AWS console)
  
  > **Comments:**
  > **username_3**: For me, it was `ec2_centos.pem` on packer v1.4.1, obviously, I was building a CentOS VM  
  
  ---
  
  ### Answer by username_4 on 2019-07-23. Score: 1
  
  They are likely in the user's home folder, or the folder in which packer is running.
  
  You can look at `~/.ssh`, or you can specify you own [keypair](https://packer.io/docs/builders/amazon-instance.html).
  
  > **Comments:**
  > **username_5**: It is not.  Packer only emits to file (in local dir) if running in debug.  
  
  ---
  
  