{"id":551,"date":"2016-06-30T15:07:09","date_gmt":"2016-06-30T06:07:09","guid":{"rendered":"http:\/\/www.nukoneko.info\/blog\/?p=551"},"modified":"2016-06-30T15:23:13","modified_gmt":"2016-06-30T06:23:13","slug":"centos7-%e3%81%a7%e3%81%ae-ssh%e8%a8%ad%e5%ae%9a","status":"publish","type":"post","link":"https:\/\/www.nukoneko.info\/blog\/?p=551","title":{"rendered":"CentOS7 \u3067\u306e SSH\u8a2d\u5b9a"},"content":{"rendered":"<h1>CentOS7 \u3092\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3057\u305f\u6642\u306e\u30e1\u30e2<\/h1>\n<p>SSH\u516c\u958b\u9375\u8a8d\u8a3c\u3067\u63a5\u7d9a\u3059\u308b\u305f\u3081\u306e\u8a2d\u5b9a<\/p>\n<p><!--more--><\/p>\n<h2>firewall setting<\/h2>\n<p>SSH\u306e\u30dd\u30fc\u30c8\u309222\u3068\u3057\u3066\u66f8\u3044\u3066\u307e\u3059\u3002<br \/>\n\u30dd\u30fc\u30c8\u756a\u53f7\u3092\u5909\u3048\u308b\u4eba\u306f 22 \u306e\u7b87\u6240\u3092\u4efb\u610f\u306b\u8aad\u307f\u66ff\u3048\u3066\u4e0b\u3055\u3044\u3002<br \/>\n\u3059\u3079\u3066\u306e\u8a2d\u5b9a\u304c\u7d42\u308f\u308b\u307e\u3067\u3001\u30ed\u30b0\u30a2\u30a6\u30c8\u3084\u518d\u8d77\u52d5\u306f\u3057\u306a\u3044\u3088\u3046\u306b\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n### \u30dd\u30fc\u30c8\u3092\u958b\u3051\u308b\n\n## ssh\n# service\nsudo firewall-cmd --add-service=ssh\nsudo firewall-cmd --permanent --add-service=ssh\n# port\nsudo firewall-cmd --add-port=22\/tcp\nsudo firewall-cmd --permanent --add-port=22\/tcp\n\n## check\nsudo firewall-cmd --list-services\n&#x5B;\u51fa\u529b] dhcpv6-client ssh\n\nsudo firewall-cmd --list-ports\n&#x5B;\u51fa\u529b] 22\/tcp\n\n## firewalld restart\nsudo systemctl restart firewalld\n<\/pre>\n<h2>ssh setting<\/h2>\n<p>user setting<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n## \u3082\u3057\u30e6\u30fc\u30b6\u30fc\u3092\u307e\u3060\u4f5c\u3063\u3066\u3044\u306a\u3044\u306a\u3089 ##\n# create user\nsudo useradd username\n\n# go user homedir\nsudo su username\n&#x5B;username@hostname hoge] cd\n\n## \u3053\u3053\u304b\u3089\u30e6\u30fc\u30b6\u30fc\u306e\u30db\u30fc\u30e0\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\n\n# make .ssh dir\n&#x5B;username@hostname ~] mkdir .ssh\n&#x5B;username@hostname ~] chmod 700 .ssh\n&#x5B;username@hostname ~] cd .ssh\n\n## sshkey generate \/ set\n#    1. send id_rsa to myPC after create\n# or 2. send id_rsa from myPC to set .ssh\/id_rsa (easy)\n# below information is 1.\n\n## SSH\u9375\u306e\u751f\u6210\u3068\u8a2d\u5b9a\u306b\u3064\u3044\u3066\n#  1. SSH\u9375\u3092\u4f5c\u6210\u5f8c\u3001\u306a\u3093\u3089\u304b\u306e\u65b9\u6cd5\u3067\u81ea\u5206\u306ePC(\u3053\u3053\u306b\u63a5\u7d9a\u3059\u308b\u30de\u30b7\u30f3)\u306b\u9001\u308b\n#  2. \u81ea\u5206\u306ePC\u3067\u9375\u3092\u4f5c\u6210\u5f8c\u3001\u306a\u3093\u3089\u304b\u306e\u65b9\u6cd5\u3067id_rsa.pub\u3092\u9001\u308b (\u697d)\n&#x5B;username@hostname .ssh] ssh-keygen -t rsa\n&#x5B;username@hostname .ssh] mv id_rsa.pub authorized_keys\n&#x5B;username@hostname .ssh] chmod 600 authorized_keys\n\n<\/pre>\n<p>sshd setting<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n&amp;lt;br \/&amp;gt;# edit sshd_config\nsudo emacs \/etc\/sshd\/sshd_config\n\n# ssh port number\n# SSH \u306b\u63a5\u7d9a\u3059\u308b\u305f\u3081\u306e\u30dd\u30fc\u30c8\u756a\u53f7\nPort 22\n\n# ssh procol version\n# SSH\u306e\u30d0\u30fc\u30b8\u30e7\u30f3 \u57fa\u672c\u7684\u306b2\nProtocol 2\n\n# disable root login\n# \u30eb\u30fc\u30c8\u30ed\u30b0\u30a4\u30f3\u3092\u7121\u52b9\u306b\nPermitRootLogin no\n\n# disable use password login\n# \u30d1\u30b9\u30ef\u30fc\u30c9\u30ed\u30b0\u30a4\u30f3\u3092\u7121\u52b9\u306b\nPasswordAuthentication no\n\n# allow users setting\n# SSH\u63a5\u7d9a\u304c\u3067\u304d\u308b\u30e6\u30fc\u30b6\u30fc\u540d\u3092\u8ffd\u52a0\nAllowUsers username\n# \u8907\u6570\u306e\u6642\u306f\n# AllowUsers user1 user2 user3\n# \u63a5\u7d9a\u30db\u30b9\u30c8\u540d\u307e\u3067\u6307\u5b9a\u3057\u305f\u304b\u3063\u305f\u3089\n# AllowUsers user1@hoge.host.jp\n\n# disable rhost RSA\n# rhosts \u3092\u4f7f\u3063\u305f\u8a8d\u8a3c\u3092\u62d2\u5426\nRhostsRSAAuthentication no\n\n# disable host based Auth\n# \u30db\u30b9\u30c8\u30d9\u30fc\u30b9\u8a8d\u8a3c\u3092\u62d2\u5426\nHostbasedAuthentication no\n\n# RSA Auth disable\n# RSA\u8a8d\u8a3c\u3092\u62d2\u5426 RSA\u306f\u57fa\u672c\u7684\u306bSSH1\u307e\u3067\u3060\u3063\u305f\nRSAAuthentication no\n\n# enable PublicKeyAuthorization\n# \u516c\u958b\u9375\u8a8d\u8a3c\u3092\u8a31\u53ef\nPubkeyAuthentication yes\n\n# user publickey position\n# \u516c\u958b\u9375\u306e\u5834\u6240\u3092\u6307\u5b9a\nAuthorizedKeysFile      .ssh\/authorized_keys\n# .ssh\/authorized_keys \u306f \u30e6\u30fc\u30b6\u30fc\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u4e2d\u306e.ssh\/authorized_keys \n# \u4f8b \/home\/username\/.ssh\/authorized_keys\n\n# .ssh\/known_hosts \u3067\u8a31\u53ef\u3057\u305f\u30db\u30b9\u30c8\u516c\u958b\u9375\u3078\u306e\u53c2\u7167\u3092\u62d2\u5426\u3059\u308b\u304b\u3069\u3046\u304b\n# \u30db\u30b9\u30c8\u30d9\u30fc\u30b9\u3058\u3083\u306a\u3044\u304b\u3089\u308f\u304b\u3089\u306a\u3044\u3051\u3069\u3068\u308a\u3042\u3048\u305ayes\u3067..\nIgnoreUserKnownHosts yes\n\n#----------------------------\n\n# restart\nsudo systemctl restart sshd\n<\/pre>\n<p>\u304a\u75b2\u308c\u69d8\u3067\u3057\u305f<\/p>\n","protected":false},"excerpt":{"rendered":"<p>CentOS7 \u3092\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3057\u305f\u6642\u306e\u30e1\u30e2 SSH\u516c\u958b\u9375\u8a8d\u8a3c\u3067\u63a5\u7d9a\u3059\u308b\u305f\u3081\u306e\u8a2d\u5b9a<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":["post-551","post","type-post","status-publish","format-standard","hentry","category-centos"],"_links":{"self":[{"href":"https:\/\/www.nukoneko.info\/blog\/index.php?rest_route=\/wp\/v2\/posts\/551","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nukoneko.info\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nukoneko.info\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nukoneko.info\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nukoneko.info\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=551"}],"version-history":[{"count":8,"href":"https:\/\/www.nukoneko.info\/blog\/index.php?rest_route=\/wp\/v2\/posts\/551\/revisions"}],"predecessor-version":[{"id":559,"href":"https:\/\/www.nukoneko.info\/blog\/index.php?rest_route=\/wp\/v2\/posts\/551\/revisions\/559"}],"wp:attachment":[{"href":"https:\/\/www.nukoneko.info\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=551"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nukoneko.info\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=551"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nukoneko.info\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=551"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}