---
title: 'HOWTO: Automatically import your public SSH keys into LXD Instances'
description: Just another reason why LXD is so awesome…You can easily configure your
  own cloud-init configuration into your LXD instance profile.In my case, I want cloud-init
  to automatically ssh-import-id kirkland, to fetch my keys from Launchpad.  Alternat
  […]
url: https://canonical.com/blog/howto-automatically-import-your-public-ssh-keys-into-lxd-instances?format=md
---

1. [Blog](https://canonical.com/blog)
2. Article

---

[Dustin Kirkland](https://canonical.com/blog/author/kirkland "More about Dustin Kirkland")

25 February 2017

# HOWTO: Automatically import your public SSH keys into LXD Instances

[cloud-init](https://canonical.com/blog/tag/cloud-init)
[containers](https://canonical.com/blog/tag/containers)
[LXD](https://canonical.com/blog/tag/lxd)

---

Share the article

Just another reason why [LXD](http://linuxcontainers.org/) is so awesome…

You can easily configure your own cloud-init configuration into your LXD instance profile.

In my case, I want *[cloud-init](http://cloud-init.org/)* to automatically ssh-import-id kirkland, to fetch my keys from Launchpad.  Alternatively, I could use gh:dustinkirkland to fetch my keys from Github.

Here’s how!

First, edit your default LXD profile (or any other, for that matter):

```
$ lxc profile edit default
```

Then, add the config snippet, like this:

```
config:
  user.vendor-data: |
    #cloud-config
    users:
      - name: root
        ssh-import-id: gh:dustinkirkland
        shell: /bin/bash
description: Default LXD profile
devices:
  eth0:
    name: eth0
    nictype: bridged
    parent: lxdbr0
    type: nic
name: default
```

Save and quit in your interactive editor, and then launch a new instance:

```
$ lxc launch ubuntu:x
Creating amazed-manatee
Starting amazed-manatee
```

Find your instance’s IP address:

```
$ lxc list
+----------------+---------+----------------------+----------------------------------------------+------------+-----------+
|      NAME      |  STATE  |         IPV4         |                     IPV6                     |    TYPE    | SNAPSHOTS |
+----------------+---------+----------------------+----------------------------------------------+------------+-----------+
| amazed-manatee | RUNNING | 10.163.22.135 (eth0) | fdce:be5e:b787:f7d2:216:3eff:fe1c:773 (eth0) | PERSISTENT | 0         |
+----------------+---------+----------------------+----------------------------------------------+------------+-----------+
```

And now SSH in!

```
$ ssh ubuntu@10.163.22.135
$ ssh -6 ubuntu@fdce:be5e:b787:f7d2:216:3eff:fe1c:773
```

Enjoy!

:-Dustin

## Sign up for our newsletter

Get the latest Canonical news and updates in your inbox.

Work email:

\*I agree to receive information about Canonical's
products and services.

By submitting this form, I confirm that I have read and agree to [Canonical's Privacy Policy](https://canonical.com/legal/dataprivacy).

Sign up

## Share on

---

## Related posts

[### Ubuntu Server: a platform made for enterprise scale](https://canonical.com/blog/ubuntu-server-a-platform-made-for-enterprise-scale)

A platform is an environment that allows software to run smoothly across the infrastructure, runtime, and application layers. The key word there is “smoothly”: a good platform...

[Rhys Knipe](https://canonical.com/blog/author/rhysknipe)

7 July 2026

[### Canonical partners with Snyk for scanning chiseled Ubuntu containers](https://canonical.com/blog/canonical-partners-with-snyk-for-scanning-chiseled-ubuntu-containers)

Canonical, the publisher of Ubuntu, is pleased to announce a new partnership with developer-focused cybersecurity company Snyk. Snyk Container, Snyk’s container security...

[Canonical](https://canonical.com/blog/author/canonical)

20 March 2026

[### Introducing MicroCloud Cluster Manager](https://canonical.com/blog/introducing-microcloud-cluster-manager)

Canonical introduces the beta release of MicroCloud Cluster Manager, a new way to discover, organize, and operate your MicroCloud environments from a single, unified interface.

[Miona Aleksic](https://canonical.com/blog/author/mionaalex)

20 March 2026

[### Native integration available between Canonical LXD and HPE Alletra MP B10000](https://canonical.com/blog/canonical_lxd_hpe_alletra)

Native integration available between Canonical LXD and HPE Alletra MP B10000. The integration combines efficient open source virtualization with high performance,...

[Miona Aleksic](https://canonical.com/blog/author/mionaalex)

15 December 2025
