<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>

CC BY-SA 4.0
2020-06-18T07:40:04.313Z
For me, it was `ec2_centos.pem` on packer v1.4.1, obviously, I was building a CentOS VM
vikas027
CC BY-SA 4.0
2019-07-25T23:34:05.890Z
2019-07-25T23:34:05.890Z
Philipp Claßen
<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>

CC BY-SA 4.0
2020-09-22T14:00:12.653Z
It is not.  Packer only emits to file (in local dir) if running in debug.
Eddie
CC BY-SA 4.0
2019-07-23T09:48:00.247Z
2019-07-24T10:19:14.390Z
2019-07-24T10:19:14.390Z
Matthieu Ducorps
<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>

CC BY-SA 4.0
2019-07-25T07:07:27.970Z
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)
Bruce Becker
<packer>
Is it possible to locate the temp keypair generated by Packer?
armandomiani
# 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@

(where  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.  

---

