{"id":2243,"date":"2013-06-28T10:22:52","date_gmt":"2013-06-28T09:22:52","guid":{"rendered":"http:\/\/blog.campodoro.org\/?p=2243"},"modified":"2013-06-28T10:30:42","modified_gmt":"2013-06-28T09:30:42","slug":"cisco-sg300-sg500-switch-ssh-public-key-authentication","status":"publish","type":"post","link":"https:\/\/blog.campodoro.org\/?p=2243","title":{"rendered":"Cisco SG300 \/ SG500 switch SSH Public key authentication"},"content":{"rendered":"<p>Argh! I wasn&#8217;t able to paste my public SSH key into the switch&#8217;s GUI (keeps on giving me a very annoying error:<\/p>\n<p>&#8220;<strong>Invalid key string.<br \/>\nWhen a Key is entered, it should contain the &#8220;BEGIN&#8221; and &#8220;END&#8221; markers.<\/strong>&#8221;<\/p>\n<p>So, let&#8217;s try the CLI. I presume you already know how to handle a Cisco from the terminal.<\/p>\n<p><strong>&#8211; Enable ssh-server on the switch<\/strong><\/p>\n<p><span style=\"color: #ff0000;\"><code><span style=\"color: #000000;\">switchxxxxxx(config)#<\/span> ip ssh server<\/code><\/span><\/p>\n<p><strong>&#8211; Enable public key authentication<\/strong><\/p>\n<p><span style=\"color: #ff0000;\"><code><span style=\"color: #000000;\">switchxxxxxx(config)#<\/span> ip ssh pubkey-auth auto-login<\/code><\/span><\/p>\n<p><strong>&#8211; Add a user:<\/strong><\/p>\n<p><code>switchxxxxxx(config)# <span style=\"color: #ff0000;\">username martijn password SecretPassword privilege 15<\/span><\/code><\/p>\n<p><strong>&#8211; Then, add user&#8217;s public key<\/strong><\/p>\n<p><code>switchxxxxxx(config)# <span style=\"color: #ff0000;\">crypto key pubkey-chain ssh<\/span><br \/>\nswitchxxxxxx(config-pubkey-chain)# <span style=\"color: #ff0000;\">user-key martijn rsa<\/span><br \/>\nswitchxxxxxx(config-pubkey-key)# <span style=\"color: #ff0000;\">key-string<\/span><\/code><\/p>\n<p><strong><span style=\"color: #ff0000;\">(paste your id_rsa.pub here)<\/span><\/strong><\/p>\n<p><strong>&#8211; Check if the fingerprint is correct:<br \/>\n<\/strong><br \/>\n<code>switchxxxxxx# <span style=\"color: #ff0000;\">show crypto key pubkey-chain ssh<\/span><\/code><\/p>\n<p>Username Fingerprint<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8211; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\nmartijn 35:ea:60:06:fc:d7:f7:d3:3b:d1:0f:10:63:f7:0b:02<\/p>\n<p><strong>Now try to ssh to your switch; no password should be asked.<\/strong><\/p>\n<div class=\"tweetthis\" style=\"text-align:left;\"><p> <a class=\"tt\" href=\"http:\/\/twitter.com\/share?url=https:\/\/blog.campodoro.org\/?p=2243&text=Cisco+SG300+%2F+SG500+switch+SSH+Public+key+authentication+%23campodoro+%23tips+%23apple&via=goudkamp&related=richardxthripp%2Ctweetthisplugin\" title=\"Twitter\"><img decoding=\"async\" class=\"nothumb\" src=\"http:\/\/blog.campodoro.org\/wp-content\/plugins\/tweet-this\/icons\/en\/twitter\/tt-twitter.png\" alt=\"Post to Twitter\" \/><\/a> <a class=\"tt\" href=\"http:\/\/twitter.com\/share?url=https:\/\/blog.campodoro.org\/?p=2243&text=Cisco+SG300+%2F+SG500+switch+SSH+Public+key+authentication+%23campodoro+%23tips+%23apple&via=goudkamp&related=richardxthripp%2Ctweetthisplugin\" title=\"Twitter\">Tweet<\/a> <a class=\"tt\" href=\"http:\/\/delicious.com\/post?url=https:\/\/blog.campodoro.org\/?p=2243&amp;title=Cisco+SG300+%2F+SG500+switch+SSH+Public+key+authentication\" title=\"Post to Delicious\"><img decoding=\"async\" class=\"nothumb\" src=\"http:\/\/blog.campodoro.org\/wp-content\/plugins\/tweet-this\/icons\/en\/delicious\/tt-delicious.png\" alt=\"Post to Delicious\" \/><\/a> <a class=\"tt\" href=\"http:\/\/delicious.com\/post?url=https:\/\/blog.campodoro.org\/?p=2243&amp;title=Cisco+SG300+%2F+SG500+switch+SSH+Public+key+authentication\" title=\"Post to Delicious\">Post to Delicious<\/a> <a class=\"tt\" href=\"http:\/\/www.facebook.com\/share.php?u=https:\/\/blog.campodoro.org\/?p=2243&amp;t=Cisco+SG300+%2F+SG500+switch+SSH+Public+key+authentication\" title=\"Post to Facebook\"><img decoding=\"async\" class=\"nothumb\" src=\"http:\/\/blog.campodoro.org\/wp-content\/plugins\/tweet-this\/icons\/en\/facebook\/tt-facebook.png\" alt=\"Post to Facebook\" \/><\/a> <a class=\"tt\" href=\"http:\/\/www.facebook.com\/share.php?u=https:\/\/blog.campodoro.org\/?p=2243&amp;t=Cisco+SG300+%2F+SG500+switch+SSH+Public+key+authentication\" title=\"Post to Facebook\">Post to Facebook<\/a><\/p><\/div>","protected":false},"excerpt":{"rendered":"<p>Argh! I wasn&#8217;t able to paste my public SSH key into the switch&#8217;s GUI (keeps on giving me a very annoying error: &#8220;Invalid key string. When a Key is entered, it should contain the &#8220;BEGIN&#8221; and &#8220;END&#8221; markers.&#8221; So, let&#8217;s &hellip; <a href=\"https:\/\/blog.campodoro.org\/?p=2243\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14,187],"tags":[193,188,192,155,191,190,194,195,189],"class_list":["post-2243","post","type-post","status-publish","format-standard","hentry","category-aaaarghh","category-cisco","tag-authentication","tag-cisco-2","tag-key","tag-network","tag-public","tag-server","tag-sg300","tag-sg500","tag-ssh"],"_links":{"self":[{"href":"https:\/\/blog.campodoro.org\/index.php?rest_route=\/wp\/v2\/posts\/2243"}],"collection":[{"href":"https:\/\/blog.campodoro.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.campodoro.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.campodoro.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.campodoro.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2243"}],"version-history":[{"count":5,"href":"https:\/\/blog.campodoro.org\/index.php?rest_route=\/wp\/v2\/posts\/2243\/revisions"}],"predecessor-version":[{"id":2248,"href":"https:\/\/blog.campodoro.org\/index.php?rest_route=\/wp\/v2\/posts\/2243\/revisions\/2248"}],"wp:attachment":[{"href":"https:\/\/blog.campodoro.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2243"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.campodoro.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2243"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.campodoro.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2243"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}