# Invalid SSH Key

**URL:** <https://forums.balena.io/t/invalid-ssh-key/1225>\
**Category:** Product support\
**Tags:** ssh\
**Created:** [June 13, 2017, 6:02pm UTC](https://forums.balena.io/t/invalid-ssh-key/1225 "2017-06-13T18:02:36Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![dagrooms52](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/dagrooms52/32/532_2.png) [@dagrooms52](https://forums.balena.io/u/dagrooms52)\
**Post date:** [June 13, 2017, 6:02pm UTC](https://forums.balena.io/t/invalid-ssh-key/1225/1 "2017-06-13T18:02:36Z")

</div>

I generated an SSH key on an Ubuntu VM, and am unable to submit it to my resin account, with the error “Invalid Key” when I submit. Generally, the key files have 3 parts, “ssh-rsa”, the key itself, and the user’s email address. I have tried the key alone, and every possible combination of the key with the other two parts to no avail. I was able to get this to work with a key generated on my Macbook, but not on the Ubuntu VM.

---

<div class="post-metadata">

**Author:** ![dagrooms52](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/dagrooms52/32/532_2.png) [@dagrooms52](https://forums.balena.io/u/dagrooms52)\
**Post date:** [June 13, 2017, 9:14pm UTC](https://forums.balena.io/t/invalid-ssh-key/1225/2 "2017-06-13T21:14:40Z")

</div>

Worked around it by adding my ssh key to GitHub and then importing the key from GitHub - just in case anyone else hits this issue.

---

<div class="post-metadata">

**Author:** ![pcarranzav](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/pcarranzav/32/94_2.png) [@pcarranzav](https://forums.balena.io/u/pcarranzav)\
**Post date:** [June 13, 2017, 10:14pm UTC](https://forums.balena.io/t/invalid-ssh-key/1225/3 "2017-06-13T22:14:05Z")

</div>

Hi @dagrooms52 - that sounds weird. It should be the full .pub file that has to be added. How did you generate the key exactly?

---

<div class="post-metadata">

**Author:** ![dagrooms52](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/dagrooms52/32/532_2.png) [@dagrooms52](https://forums.balena.io/u/dagrooms52)\
**Post date:** [June 13, 2017, 10:26pm UTC](https://forums.balena.io/t/invalid-ssh-key/1225/4 "2017-06-13T22:26:29Z")

</div>

I generated the key using the steps outlined in the GitHub SSH key tutorial, this link: [https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/](https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/)  
I followed them exactly on my Mac and on the Ubuntu VM.

---

<div class="post-metadata">

**Author:** ![Eugene](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/eugene/32/42_2.png) [@Eugene](https://forums.balena.io/u/Eugene)\
**Post date:** [June 14, 2017, 7:37am UTC](https://forums.balena.io/t/invalid-ssh-key/1225/5 "2017-06-14T07:37:40Z")

</div>

Hi. We’ve created an issue to investigate the problem and fix as needed, will get back to you as soon as it’s done.

---

<div class="post-metadata">

**Author:** ![thgreasi](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/thgreasi/32/454_2.png) [@thgreasi](https://forums.balena.io/u/thgreasi)\
**Post date:** [June 15, 2017, 7:28am UTC](https://forums.balena.io/t/invalid-ssh-key/1225/6 "2017-06-15T07:28:07Z")

</div>

Hi, we have a fix for the issue, which just got deployed.  
Thank you for your report! Best, Thodoris

---

<div class="post-metadata">

**Author:** ![dagrooms52](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/dagrooms52/32/532_2.png) [@dagrooms52](https://forums.balena.io/u/dagrooms52)\
**Post date:** [June 15, 2017, 1:17pm UTC](https://forums.balena.io/t/invalid-ssh-key/1225/7 "2017-06-15T13:17:28Z")

</div>

Thanks all of you for the quick responses and fix!

---

<div class="post-metadata">

**Author:** ![tlawrence](https://avatars.discourse-cdn.com/v4/letter/t/c0e974/32.png) [@tlawrence](https://forums.balena.io/u/tlawrence)\
**Post date:** [September 10, 2018, 5:06pm UTC](https://forums.balena.io/t/invalid-ssh-key/1225/8 "2018-09-10T17:06:10Z")

</div>

I’m having the same issue. Generated at home on Windows using Windows Bash - worked fine. Generated using Windows Bash at work - says invalid key. Importing from GitHub works fine.

---

<div class="post-metadata">

**Author:** ![banto\_78](https://avatars.discourse-cdn.com/v4/letter/b/7c8e57/32.png) [@banto\_78](https://forums.balena.io/u/banto_78)\
**Post date:** [July 1, 2019, 9:10am UTC](https://forums.balena.io/t/invalid-ssh-key/1225/11 "2019-07-01T09:10:56Z")

</div>

> [@thgreasi](#):
>
> ve a fix for the issue, which just got deployed.

I have same issue on Ubuntu. Is it really fixed?

---

<div class="post-metadata">

**Author:** ![mikesimos](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/mikesimos/32/1418_2.png) [@mikesimos](https://forums.balena.io/u/mikesimos)\
**Post date:** [July 1, 2019, 9:18am UTC](https://forums.balena.io/t/invalid-ssh-key/1225/12 "2019-07-01T09:18:15Z")

</div>

Hi there! How did you generate your key? What’s the error message you 'r getting? Were you able to reproduce this consistently? Could you share your **public key** as it isn’t sensitive, or add it to a github account, and share your github username?  
Thanks!

---

<div class="post-metadata">

**Author:** ![banto\_78](https://avatars.discourse-cdn.com/v4/letter/b/7c8e57/32.png) [@banto\_78](https://forums.balena.io/u/banto_78)\
**Post date:** [July 1, 2019, 9:43am UTC](https://forums.balena.io/t/invalid-ssh-key/1225/14 "2019-07-01T09:43:19Z")

</div>

keys generated with tutorial command:  
ssh-keygen -t rsa -b 4096 -C "xxxxx@xxxx.com"  
And got key as:

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQD1KyTMhw0aokk/oNxELgX7vjKZXn84htbPJ78819i/1oOY0aeptxWyhqfgfNOsBrJ5L0XZv/+CzQM0nfQZEie5U/VpdXeRdnbgJR4Vu+Zb7/lvMaRr/LN3cJM/yqE9WzdzB0uFJ89Omdy6AoJe+aohUEJ351O8nutf/Nuu0H6U8hFjOEW4eIIc2tbQ8tPVdvTU29R6f  
P+Aid28v5ZfZYzfidb37t8mwMTxxlh49nfkC+4RvDZHA7gpT0YJA6HeVuug1CdF8hgPKifejDBXyBEkzEnih2PUQuaMGR3/stvp9uLPFr0cXacvklvxIOz7f8aHCachLmenQvUGU+yJfNi2EsMAG4p/6ubwgLE8BSoUCTWeb5LCgZOGu2UN9yUf6t/miGw1tOZg3DTn/8aQ8c5mu3qNzy0t3y31lrRcpd2hSM0WXKVoB1  
+ylaE0Sun8YxgDE9h81pj5bLX8ooNjNWsz53xAvzwn7HsXjzq+JlBmwjpG1EckRzmkGaPSlz36JNTsBELDiZSonhhQ6/m/EF9DJxSobbE2oChiNoLOysH1+FHAThnMizSrC3LUUxJyGyP8wdM+HMOXVygEbRTwnJvwh2jdUYvEkEVoUYte7HpkA64ct2yDYyjei1nuxYDmBYHqeZzaceT0bXGboW/4Psux4b289DAHaVI  
FwY3UdMSFWw== [xxx@xxxx.com](mailto:xxx@xxxx.com)

I’ve got always “Invalid Key” message when adding it manually. Workaround is to add it in Git and import it from there…

---

<div class="post-metadata">

**Author:** ![mikesimos](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/mikesimos/32/1418_2.png) [@mikesimos](https://forums.balena.io/u/mikesimos)\
**Post date:** [July 1, 2019, 10:07am UTC](https://forums.balena.io/t/invalid-ssh-key/1225/20 "2019-07-01T10:07:56Z")

</div>

Hi @banto_78, the above public key appears to be invalid. The reason is some added newlines (probably during copy-paste).  
For checking your key validity, you can run `ssh-keygen -l -f /path/to/public_key`.  
You should be able to import the key successfully, after removing the additional newlines from the public key body:

```auto
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQD1KyTMhw0aokk/oNxELgX7vjKZXn84htbPJ78819i/1oOY0aeptxWyhqfgfNOsBrJ5L0XZv/+CzQM0nfQZEie5U/VpdXeRdnbgJR4Vu+Zb7/lvMaRr/LN3cJM/yqE9WzdzB0uFJ89Omdy6AoJe+aohUEJ351O8nutf/Nuu0H6U8hFjOEW4eIIc2tbQ8tPVdvTU29R6fP+Aid28v5ZfZYzfidb37t8mwMTxxlh49nfkC+4RvDZHA7gpT0YJA6HeVuug1CdF8hgPKifejDBXyBEkzEnih2PUQuaMGR3/stvp9uLPFr0cXacvklvxIOz7f8aHCachLmenQvUGU+yJfNi2EsMAG4p/6ubwgLE8BSoUCTWeb5LCgZOGu2UN9yUf6t/miGw1tOZg3DTn/8aQ8c5mu3qNzy0t3y31lrRcpd2hSM0WXKVoB1+ylaE0Sun8YxgDE9h81pj5bLX8ooNjNWsz53xAvzwn7HsXjzq+JlBmwjpG1EckRzmkGaPSlz36JNTsBELDiZSonhhQ6/m/EF9DJxSobbE2oChiNoLOysH1+FHAThnMizSrC3LUUxJyGyP8wdM+HMOXVygEbRTwnJvwh2jdUYvEkEVoUYte7HpkA64ct2yDYyjei1nuxYDmBYHqeZzaceT0bXGboW/4Psux4b289DAHaVIFwY3UdMSFWw==

```
