# balena account ssh pub key automatically insert into config.json image?

**URL:** <https://forums.balena.io/t/balena-account-ssh-pub-key-automatically-insert-into-config-json-image/228966>\
**Category:** balenaOS\
**Created:** [December 23, 2020, 10:43pm UTC](https://forums.balena.io/t/balena-account-ssh-pub-key-automatically-insert-into-config-json-image/228966 "2020-12-23T22:43:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ealmonte32](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/ealmonte32/32/5168_2.png) [@ealmonte32](https://forums.balena.io/u/ealmonte32)\
**Post date:** [December 23, 2020, 10:43pm UTC](https://forums.balena.io/t/balena-account-ssh-pub-key-automatically-insert-into-config-json-image/228966/1 "2020-12-23T22:43:56Z")

</div>

I read some of the posts about people having issues with non balena-cli SSH connections and when trying to connect directly to Host OS with `ssh -p 22222 root@device` they got permission denied because of public-key not being in the `.ssh/authorized_keys` file… which can get the key from the `config.json` file…

I understand that users need to know how to properly set up/configure/generate their `id_rsa` and `id_rsa.pub` key pair, making sure the pub key is in the balena account preferences SSH keys section, and manually inserting this pub key in the `resin-boot/config.json` file’s sshKeys array by manually creating this section:

```auto
	"os": {
		"sshKeys": ["ssh-rsa PUBKEYHERE"]
	}

```

It works of course, but I am wondering why the process of app/balena image creation doesn’t automatically insert the balena account holders public ssh key(s) into the config.json for you?

I can’t at the moment think of a reason why the public key(s) which is meant to be public of course, isn’t automatically inserted for normal users upon this balena image generation process so that the user doesn’t have to manually edit the config.json file and insert this sshKeys section and all of that, for all the devices the user wants to have SSH access to…  
If it’s a security reason, again, the public key is meant to be public so it’s not like it will make any difference if the SD card with the balena image is used outside of your control since the private key for this pub key remains on your computer, no one except the computer with the private key will be able to SSH to it anyway…

Thanks for any input on this.

---

<div class="post-metadata">

**Author:** ![majorz](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/majorz/32/639_2.png) [@majorz](https://forums.balena.io/u/majorz)\
**Post date:** [December 24, 2020, 1:05pm UTC](https://forums.balena.io/t/balena-account-ssh-pub-key-automatically-insert-into-config-json-image/228966/4 "2020-12-24T13:05:21Z")

</div>

I personally find this idea quite neat. I imagine it as an option with a checkbox for including it when downloading an image. I am going to pass this for further discussion internally and we will get back to you with more information.

---

<div class="post-metadata">

**Author:** ![majorz](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/majorz/32/639_2.png) [@majorz](https://forums.balena.io/u/majorz)\
**Post date:** [December 28, 2020, 11:58am UTC](https://forums.balena.io/t/balena-account-ssh-pub-key-automatically-insert-into-config-json-image/228966/7 "2020-12-28T11:58:41Z")

</div>

There is an ongoing related feature request ([https://github.com/balena-io/balena-ui/issues/4270](https://github.com/balena-io/balena-ui/issues/4270)) to which I linked your request. Those will most probably be implemented all at once.

---

<div class="post-metadata">

**Author:** ![ealmonte32](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/ealmonte32/32/5168_2.png) [@ealmonte32](https://forums.balena.io/u/ealmonte32)\
**Post date:** [December 30, 2020, 3:37am UTC](https://forums.balena.io/t/balena-account-ssh-pub-key-automatically-insert-into-config-json-image/228966/9 "2020-12-30T03:37:26Z")

</div>

@majorz  
Thanks for forwarding internally…  
I knew I couldn’t be the only one who thought this would be a neat idea. 🙂  
Is that GitHub issues link public? It’s giving me a 404 error…

---

<div class="post-metadata">

**Author:** ![anujdeshpande](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/anujdeshpande/32/3155_2.png) [@anujdeshpande](https://forums.balena.io/u/anujdeshpande)\
**Post date:** [December 30, 2020, 7:10am UTC](https://forums.balena.io/t/balena-account-ssh-pub-key-automatically-insert-into-config-json-image/228966/10 "2020-12-30T07:10:25Z")

</div>

Hi

Oops! That’s indeed a private repo so you won’t be able to see the github issue! I have internally linked it to this forum thread though - so when we have an update on that we will update this thread as well.
