{"id":5214,"date":"2023-06-06T23:16:00","date_gmt":"2023-06-07T04:16:00","guid":{"rendered":"https:\/\/www.incredigeek.com\/home\/?p=5214"},"modified":"2023-06-06T23:02:52","modified_gmt":"2023-06-07T04:02:52","slug":"how-to-create-a-preshared-key-for-wireguard","status":"publish","type":"post","link":"https:\/\/www.incredigeek.com\/home\/how-to-create-a-preshared-key-for-wireguard\/","title":{"rendered":"How to Create a Preshared Key for Wireguard"},"content":{"rendered":"\n<p>You may have encountered a Mikrotik error when trying to create preshared key<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Couldn't change wireguard peer&lt;> - invalid preshared key (6)<\/pre>\n\n\n\n<p>This is because a Wireguard preshared key needs to be 256bit (32 byte) base64 encoded key.  We have a couple different ways we can generate the correct format.  <\/p>\n\n\n\n<p>1. Use Openssl to generate a random 32 byte password<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">openssl rand 32 | base64<\/pre>\n\n\n\n<p>2. Create a 31 character password and base64 encode it<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">echo Thisisthepassword31characterslo | base64\nVGhpc2lzdGhlcGFzc3dvcmQzMWNoYXJhY3RlcnNsbwo=<\/pre>\n\n\n\n<p>Now we can take this and add it to our config.  The config option is <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">PresharedKey = VGhpc2lzdGhlcGFzc3dvcmQzMWNoYXJhY3RlcnNsbwo=<\/pre>\n\n\n\n<p><a href=\"https:\/\/www.wireguard.com\/papers\/wireguard.pdf\">https:\/\/www.wireguard.com\/papers\/wireguard.pdf<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/forum.mikrotik.com\/viewtopic.php?t=184469\">https:\/\/forum.mikrotik.com\/viewtopic.php?t=184469<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>You may have encountered a Mikrotik error when trying to create preshared key Couldn&#8217;t change wireguard peer&lt;> &#8211; invalid preshared key (6) This is because a Wireguard preshared key needs to be 256bit (32 byte) base64 encoded key. We have &hellip; <a href=\"https:\/\/www.incredigeek.com\/home\/how-to-create-a-preshared-key-for-wireguard\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[573],"tags":[390,200,503,924,1334],"class_list":["post-5214","post","type-post","status-publish","format-standard","hentry","category-security","tag-openssl","tag-password","tag-security","tag-vpn","tag-wireguard"],"_links":{"self":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/5214","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/comments?post=5214"}],"version-history":[{"count":2,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/5214\/revisions"}],"predecessor-version":[{"id":5217,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/5214\/revisions\/5217"}],"wp:attachment":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/media?parent=5214"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/categories?post=5214"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/tags?post=5214"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}