{"id":9369,"date":"2013-11-01T15:06:50","date_gmt":"2013-11-01T20:06:50","guid":{"rendered":"http:\/\/jianmingli.com\/wp\/?p=9369"},"modified":"2014-05-23T12:36:05","modified_gmt":"2014-05-23T17:36:05","slug":"setup-ssh-secure-shell-client-public-key-authentication-for-centos-ssh-server","status":"publish","type":"post","link":"https:\/\/jianmingli.com\/wp\/?p=9369","title":{"rendered":"Setup SSH Secure Shell Client Public Key Authentication for CentOS SSH Server"},"content":{"rendered":"<div class='toc wptoc'>\n<h2>Contents<\/h2>\n<ol class='toc-odd level-1'>\n\t<li>\n\t\t<a href=\"#Env\">Env<\/a>\n\t<\/li>\n\t<li>\n\t\t<a href=\"#Generate_Private_Key\">Generate Private Key<\/a>\n\t<\/li>\n\t<li>\n\t\t<a href=\"#Setup_Public_Key_in_CentOS\">Setup Public Key in CentOS<\/a>\n\t\t<ol class='toc-even level-2'>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Copy_Public_Key\">Copy Public Key<\/a>\n\t\t\t<\/li>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Setup_Public_Key_in_CentOS_1\">Setup Public Key in CentOS<\/a>\n\t\t\t<\/li>\n\t\t<\/ol>\n\t<li>\n\t\t<a href=\"#References\">References<\/a>\n\t<\/li>\n<\/ol>\n<\/ol>\n<\/div>\n<div class='wptoc-end'>&nbsp;<\/div>\n<span id=\"Env\"><h2>Env<\/h2><\/span>\n<p>* SSH Secure Shell 3.2.9 (Build 283) from SSH Communications Security Corp<br \/>\n* CentOS 5.6<\/p>\n<span id=\"Generate_Private_Key\"><h2>Generate Private Key<\/h2><\/span>\n<p>* Open SSH Secure Shell client<br \/>\n* Select <em>Edit > Settings > Global Settings > User Authentication > Keys<\/em><br \/>\n* Click <em>Generate New<\/em> button<\/p>\n<span id=\"\"><h6><a href=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2013\/11\/secureShellPubKeyAuth_settings_1.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2013\/11\/secureShellPubKeyAuth_settings_1-300x273.jpg\" alt=\"\" title=\"secureShellPubKeyAuth_settings_1\" width=\"300\" height=\"273\" class=\"aligncenter size-medium wp-image-9370\" srcset=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2013\/11\/secureShellPubKeyAuth_settings_1-300x273.jpg 300w, https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2013\/11\/secureShellPubKeyAuth_settings_1.jpg 574w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/h6><\/span>\n<p>* Select:<br \/>\n&#8211; Key Type RSA<br \/>\n&#8211; Key Length: 2048<\/p>\n<span id=\"_1\"><h6><a href=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2013\/11\/secureShellPubKeyAuth_settings_2.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2013\/11\/secureShellPubKeyAuth_settings_2-300x245.jpg\" alt=\"\" title=\"secureShellPubKeyAuth_settings_2\" width=\"300\" height=\"245\" class=\"aligncenter size-medium wp-image-9371\" srcset=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2013\/11\/secureShellPubKeyAuth_settings_2-300x245.jpg 300w, https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2013\/11\/secureShellPubKeyAuth_settings_2.jpg 432w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/h6><\/span>\n<p>* Click Next when key generation process has completed<\/p>\n<span id=\"_2\"><h6><a href=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2013\/11\/secureShellPubKeyAuth_settings_3.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2013\/11\/secureShellPubKeyAuth_settings_3-300x245.jpg\" alt=\"\" title=\"secureShellPubKeyAuth_settings_3\" width=\"300\" height=\"245\" class=\"aligncenter size-medium wp-image-9372\" srcset=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2013\/11\/secureShellPubKeyAuth_settings_3-300x245.jpg 300w, https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2013\/11\/secureShellPubKeyAuth_settings_3.jpg 433w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/h6><\/span>\n<p>* Enter file name and passphrase<\/p>\n<span id=\"_3\"><h6><a href=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2013\/11\/secureShellPubKeyAuth_settings_4.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2013\/11\/secureShellPubKeyAuth_settings_4-300x243.jpg\" alt=\"\" title=\"secureShellPubKeyAuth_settings_4\" width=\"300\" height=\"243\" class=\"aligncenter size-medium wp-image-9373\" srcset=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2013\/11\/secureShellPubKeyAuth_settings_4-300x243.jpg 300w, https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2013\/11\/secureShellPubKeyAuth_settings_4.jpg 438w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/h6><\/span>\n<p>* Click Finish<\/p>\n<span id=\"_4\"><h6><a href=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2013\/11\/secureShellPubKeyAuth_settings_5.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2013\/11\/secureShellPubKeyAuth_settings_5-300x245.jpg\" alt=\"\" title=\"secureShellPubKeyAuth_settings_5\" width=\"300\" height=\"245\" class=\"aligncenter size-medium wp-image-9374\" srcset=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2013\/11\/secureShellPubKeyAuth_settings_5-300x245.jpg 300w, https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2013\/11\/secureShellPubKeyAuth_settings_5.jpg 437w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/h6><\/span>\n<span id=\"Setup_Public_Key_in_CentOS\"><h2>Setup Public Key in CentOS<\/h2><\/span>\n<span id=\"Copy_Public_Key\"><h3>Copy Public Key<\/h3><\/span>\n<p>* From SSH Secure Shell client<br \/>\n* Select <em>Edit > Settings > Global Settings > User Authentication > Keys<\/em><br \/>\n* Click <em>Public key management > View&#8230;<\/em><\/p>\n<span id=\"_5\"><h6><a href=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2013\/11\/secureShellPubKeyAuth_settings_6_viewPubKey.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2013\/11\/secureShellPubKeyAuth_settings_6_viewPubKey-300x266.jpg\" alt=\"\" title=\"secureShellPubKeyAuth_settings_6_viewPubKey\" width=\"300\" height=\"266\" class=\"aligncenter size-medium wp-image-9375\" srcset=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2013\/11\/secureShellPubKeyAuth_settings_6_viewPubKey-300x266.jpg 300w, https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2013\/11\/secureShellPubKeyAuth_settings_6_viewPubKey.jpg 576w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/h6><\/span>\n<p>* Copy the public key text string<\/p>\n<span id=\"Setup_Public_Key_in_CentOS_1\"><h3>Setup Public Key in CentOS<\/h3><\/span>\n<p>* Login CentOS<br \/>\n* Create <strong>.ssh<\/strong> directory if it does not already exist<br \/>\n* Change to <em>.ssh<\/em> directory<\/p>\n<pre lang=\"sh\">\r\nmkdir ~\/.ssh\r\nchmod 700 ~\/.ssh\r\ncd ~\/.ssh\r\n<\/pre>\n<p>* Upload public key to <em>.ssh<\/em> directory<br \/>\n&#8211; Or you can create a file, named e.g. <strong>ssh2_key.pub<\/strong>, and cut and paste the public key string onto the the file<br \/>\n* Convert SSH2 key to OpenSSH key format and append to <strong>authorized_keys2<\/strong> file.<br \/>\n* Also chmod to 600 for the file:<\/p>\n<pre lang=\"bash\">\r\nssh-keygen -i -f ~\/.ssh\/ssh2_key.pub >> ~\/.ssh\/authorized_keys2\r\nchmod 600 ~\/.ssh\/authorized_keys2\r\n<\/pre>\n<span id=\"References\"><h2>References<\/h2><\/span>\n<p>* <a href=\"http:\/\/burnz.wordpress.com\/2007\/12\/14\/ssh-convert-openssh-to-ssh2-and-vise-versa\/\">SSH: Convert OpenSSH to SSH2 and vise versa<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Env * SSH Secure Shell 3.2.9 (Build 283) from SSH Communications Security Corp * CentOS 5.6 Generate Private Key * Open SSH Secure Shell client * Select Edit > Settings > Global Settings > User Authentication > Keys * Click &hellip; <a href=\"https:\/\/jianmingli.com\/wp\/?p=9369\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[451],"tags":[455,454,639],"class_list":["post-9369","post","type-post","status-publish","format-standard","hentry","category-ssh","tag-openssh","tag-publickey","tag-ssh"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8cRUO-2r7","_links":{"self":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/9369","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=9369"}],"version-history":[{"count":4,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/9369\/revisions"}],"predecessor-version":[{"id":10027,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/9369\/revisions\/10027"}],"wp:attachment":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9369"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9369"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9369"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}