﻿{"id":1135,"date":"2013-12-12T17:32:16","date_gmt":"2013-12-12T09:32:16","guid":{"rendered":"http:\/\/nick.txtcc.com\/?p=1135"},"modified":"2017-08-25T17:21:07","modified_gmt":"2017-08-25T09:21:07","slug":"ssh%e8%af%81%e4%b9%a6%e7%99%bb%e5%bd%95%e6%96%b9%e5%bc%8f","status":"publish","type":"post","link":"https:\/\/nick.txtcc.com\/index.php\/linux\/1135","title":{"rendered":"ssh\u8bc1\u4e66\u767b\u5f55\u65b9\u5f0f"},"content":{"rendered":"<p>\u5728\/etc\/ssh\/sshd_config\u4e2d\u5c06\u4ee5\u4e0b\u6ce8\u91ca\u53bb\u6389\uff08\u53bb\u6389\u884c\u9996\u7684\uff03\u53f7\uff09<\/p>\n<div class=\"dp-highlighter\"><\/div>\n<p>&nbsp;<\/p>\n<ol class=\"dp-c\" start=\"1\">\n    <li class=\"alt\">RSAAuthentication\u00a0yes<\/li>\n    <li>PubkeyAuthentication\u00a0yes<\/li>\n    <li class=\"alt\">\n<p class=\"p1\"><span class=\"s1\">AuthorizedKeysFile<span class=\"Apple-converted-space\">\u00a0 <\/span>%h\/.ssh\/authorized_keys<\/span><\/p>\n<\/li>\n    <li class=\"alt\">\n<p class=\"p1\"><span class=\"s1\">PasswordAuthentication no<\/span><\/p>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<p>\u52a0\u5165\u767b\u5f55\u901a\u77e5\u673a\u5236:<\/p>\n<p class=\"p1\"><span class=\"s1\">\/etc\/pam.d\/sshd<\/span><\/p>\n<p class=\"p1\">\u52a0\u5165\u00a0<span class=\"s1\">session optional pam_exec.so seteuid \/root\/notify.sh<\/span><\/p>\n<p class=\"p1\"><\/p>\n<p>linux\u4e0bssh\u767b\u5f55\u9650\u5236ip\u7684\u65b9\u6cd5<\/p>\n<p>vi \/etc\/hosts.allow\nsshd:192.168.0.100:allow \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\/\/\u5141\u8bb8IP 192.168.0.100 \u767b\u5f55\nsshd:192.168.0.:allow \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\/\/\u5141\u8bb8IP 192.168.0. \u00a0\u7f51\u6bb5\u767b\u5f55\nsshd:all:deny \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/\u7981\u6b62\u5176\u4ed6\u7684\u6240\u6709IP\u767b\u5f55\n\u6216\u8005\nsshd:223.227.223.<em>:allow \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\/\/\u5141\u8bb8IP 223.227.223.<\/em> \u00a0 \u7f51\u6bb5\u767b\u5f55\nsshd:192.168.0.<em>:allow \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\/\/\u5141\u8bb8IP 192.168.0.<\/em> \u00a0\u7f51\u6bb5\u767b\u5f55\nsshd:all:deny \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\/\/\u7981\u6b62\u5176\u4ed6\u7684\u6240\u6709IP\u767b\u5f55<\/p>\n<p>fedora\u4e0b \u4fee\u6539\u540e\u4fdd\u5b58\u540e\u751f\u6548<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #ff0000;\">\u5ba2\u6237\u7aef<\/span><\/p>\n<p>ssh\u53ef\u4ee5\u4f7f\u7528\u5bc6\u94a5\u5bf9\u4e92\u76f8\u5efa\u7acb\u4fe1\u4efb\uff0c\u4ee5\u540e\u518d\u94fe\u63a5\u4fe1\u4efb\u7684\u8ba1\u7b97\u673a\u5c31\u4e0d\u9700\u8981\u8f93\u5165\u5bc6\u7801\u4e86\u3002<\/p>\n<p>1\u3001\u5efa\u7acb\u5bc6\u94a5\u5bf9\nniu@niu:~$ ssh-keygen -t rsa\nGenerating public\/private rsa key pair.\nEnter file in which to save the key (\/home\/niu\/.ssh\/id_rsa):\nEnter passphrase (empty for no passphrase):\nEnter same passphrase again:\nYour identification has been saved in \/home\/niu\/.ssh\/id_rsa.\nYour public key has been saved in \/home\/niu\/.ssh\/id_rsa.pub.\nThe key fingerprint is:\n27:00:f4:ce:a0:6f:61:a8:55:27:af:9a:bc:2b:d5:21 niu@niu\nniu@niu:~$\n\u8fc7\u7a0b\u4e2d\u5c31\u4e00\u76f4\u6309\u56de\u8f66\u5373\u53ef\u3002\u6b64\u65f6\u4f1a\u5728 \/home\/niu\/.ssh\/ \u76ee\u5f55\u4e0b\u751f\u6210\u4e00\u5bf9\u6587\u4ef6 id_rsa, id_rsa.pub<\/p>\n<p>2\u3001\u914d\u7f6e\u8fdc\u7a0b\u8ba1\u7b97\u673a\n\u5c06id_ras.pub\u6587\u4ef6\u590d\u5236\u5230\u8fdc\u7a0b\u8ba1\u7b97\u673a\u5f85\u767b\u5f55\u7528\u6237\u4e2a\u4eba\u76ee\u5f55\u4e0b\u7684.ssh\u76ee\u5f55\u4e2d(\u5982\u4e0d\u5b58\u5728\u81ea\u5df1\u521b\u5efa)\uff0c\u5e76\u5c06\u6587\u4ef6\u540d\u6539\u4e3a authorized_keys<\/p>\n<p>3\u3001\u5b8c\u6210<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>","protected":false},"excerpt":{"rendered":"<p>\u5728\/etc\/ssh\/sshd_config\u4e2d\u5c06\u4ee5\u4e0b\u6ce8\u91ca\u53bb\u6389\uff08\u53bb\u6389\u884c\u9996\u7684\uff03\u53f7\uff09 &nbsp; RSAAuthentication\u00a0yes PubkeyAuthentication\u00a0yes Authori&#46;&#46;&#46;<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[367,440,307],"class_list":["post-1135","post","type-post","status-publish","format-standard","hentry","category-linux","tag-authorized","tag-linux","tag-ssh"],"_links":{"self":[{"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts\/1135","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/comments?post=1135"}],"version-history":[{"count":5,"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts\/1135\/revisions"}],"predecessor-version":[{"id":1641,"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts\/1135\/revisions\/1641"}],"wp:attachment":[{"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/media?parent=1135"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/categories?post=1135"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/tags?post=1135"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}