{"id":1741,"date":"2018-04-16T13:13:32","date_gmt":"2018-04-16T04:13:32","guid":{"rendered":"https:\/\/adan.jp.net\/blog\/?p=1741"},"modified":"2020-12-27T22:07:03","modified_gmt":"2020-12-27T13:07:03","slug":"centos7%e3%81%aeopenssh%e3%81%ae%e6%9b%b4%e6%96%b0%ef%bc%88%e3%82%bb%e3%82%ad%e3%83%a5%e3%82%a2%e3%81%aa%e3%82%b5%e3%83%bc%e3%83%90%e3%82%92%e4%bd%9c%e3%82%8d%e3%81%86%ef%bc%89","status":"publish","type":"post","link":"https:\/\/adan.jp.net\/blog\/programing\/1741","title":{"rendered":"CentOS7\u306eOpenSSH\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u30a2\u30c3\u30d7"},"content":{"rendered":"<p>\u3055\u304f\u3089\u30af\u30e9\u30a6\u30c9\u3067\u3001CentOS7\u3067Web\u30b5\u30fc\u30d3\u30b9\u3092\u5c55\u958b\u3059\u308b\u969b\u3001\u307e\u305a\u6700\u521d\u306b\u3084\u3063\u3066\u304a\u304d\u305f\u3044\u30a4\u30f3\u30d5\u30e9\u306e\u8a2d\u5b9a\u306e\u4e00\u3064\u306b\u3001OpenSSH\u306e\u66f4\u65b0\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\n\u4eca\u56de\u306f\u3001CentOS7\u306b\u3001\u6700\u65b0\u306eOpenSSH\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u306a\u304a\u3059\u624b\u9806\u3092\u3084\u3063\u3066\u307f\u307e\u3059\u3002<br \/>\n2020\u5e7412\u6708\u6642\u70b9\u3067\u306e\u3001\u3055\u304f\u3089\u30af\u30e9\u30a6\u30c9\u3067CentOS7\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u751f\u6210\u6642\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u306eOpenSSH\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u306f\u3001<\/p>\n<pre><code># ssh -V\nOpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 2017\n<\/code><\/pre>\n<p>\u3068\u306a\u3063\u3066\u3044\u308b\u306e\u3067\u3001<br \/>\n2020\u5e7412\u6708\u6642\u70b9\u3067\u306e\u6700\u65b0\u3001OpenSSH_7.6p1\u306b\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u3057\u3066\u307f\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u25a0root\u4ee5\u5916\u306e\u30e6\u30fc\u30b6\u3092\u4f5c\u308b<br \/>\n\u203b\u66f4\u65b0\u5f8c\u306bsshd_config\u304c\u5f37\u5236\u7684\u306b\u66f4\u65b0\u3055\u308c\u3001root\u3067\u306e\u30ed\u30b0\u30a4\u30f3\u304c\u3067\u304d\u306a\u304f\u306a\u308b\u305f\u3081<br \/>\n\u305d\u306e\u4ed6\u306e\u30e6\u30fc\u30b6\u3067\u30ed\u30b0\u30a4\u30f3\u3067\u304d\u308b\u72b6\u6cc1\u3092\u4f5c\u3063\u3066\u304a\u304d\u307e\u3057\u3087\u3046<\/p>\n<pre><code># adduser yonaha\n# passwd yonaha<\/code><\/pre>\n<p>\u305d\u306e\u5f8c\u3001SSH\u30ed\u30b0\u30a4\u30f3\u51fa\u6765\u308b\u304b\u78ba\u8a8d\u3059\u308b<\/p>\n<p>\u25a0\u5fc5\u8981\u306a\u30d1\u30c3\u30b1\u30fc\u30b8\u3092groupinstall\u3067\u3054\u305d\u3063\u3068\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b<br \/>\n\u6700\u5c0f\u9650\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u30bb\u30c3\u30c8\u3092\u3054\u305d\u3063\u3068\u3001wget\u30b3\u30de\u30f3\u30c9\u7b49\u3082\u5165\u3063\u3066\u308b<\/p>\n<pre><code># yum groupinstall -y \"Base\"<\/code><\/pre>\n<p>\u958b\u767a\u30c4\u30fc\u30eb\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u3054\u305d\u3063\u3068\u3001automake\u3001gcc\u7b49\u304c\u5165\u3063\u3066\u308b<\/p>\n<pre><code># yum groupinstall -y \"Office Suite and Productivity\" --setopt=group_package_types=mandatory,default,optional\n<\/code><\/pre>\n<p>\u203bCentOS7\u3067\u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u306a\u3044\u30aa\u30d7\u30b7\u30e7\u30f3\u30d1\u30c3\u30b1\u30fc\u30b8\u304c\u3042\u308b\u3089\u3057\u304f\u3001\u5f15\u6570\u3067\u6e21\u3057\u3066\u3042\u3052\u308b\u3084\u308a\u65b9\u3067\u89e3\u6c7a\u3059\u308b\u3068\u306e\u3053\u3068\u3067\u3059\u3001<br \/>\nRedHat\u306e\u8a18\u4e8b\u53c2\u8003 \u2192 https:\/\/access.redhat.com\/solutions\/1310043<\/p>\n<p>\u3061\u306a\u307f\u306b\u3001CentOS6\u3067\u306f\u4e0b\u8a18\u3067OK\u3067\u3059\u3002<\/p>\n<pre><code># yum groupinstall -y \"Development tools\"<\/code><\/pre>\n<p>\u5225\u9014\u4e0b\u8a18\u30d1\u30c3\u30b1\u30fc\u30b8\u3001configure\u6642\u306b\u5fc5\u8981\u306b\u306a\u308b\u306e\u3067\u5165\u308c\u3066\u304a\u304f\u3068\u30cf\u30c3\u30d4\u30fc\u304b\u3082<\/p>\n<pre><code># yum -y install zlib-devel openssl-devel rpm-build pam-devel<\/code><\/pre>\n<p>\u25a0RPM\u3092\u4f5c\u308b\u305f\u3081OpenSSH\u306e\u6700\u65b0\u306e\u30bd\u30fc\u30b9\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9<br \/>\n\u30df\u30e9\u30fc\u30b5\u30a4\u30c8\u304b\u3089\u6700\u65b0\u306e\u30bd\u30fc\u30b9\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b<\/p>\n<pre><code># wget http:\/\/ftp.jaist.ac.jp\/pub\/OpenBSD\/OpenSSH\/portable\/openssh-8.4p1.tar.gz\n# tar xzvf openssh-8.4p1.tar.gz\n<\/code><\/pre>\n<p>spec\u30d5\u30a1\u30a4\u30eb\u3092\u4fee\u6b63\u3059\u308b\u300cno_x11_askpass\u300d\u3068\u300cno_gnome_askpass\u300d\u306e\u5024\u30921\u306b\u5909\u66f4\u3059\u308b\u3002<\/p>\n<pre><code># cd openssh-8.4p1\/\n# vi contrib\/redhat\/openssh.spec\n%define no_x11_askpass 1\n%define no_gnome_askpass 1\n<\/code><\/pre>\n<p>\u4e0d\u5fc5\u8981\u306a\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u524a\u9664\u3057\u3066\u3001configure<\/p>\n<pre><code># rm -rf contrib\/aix\/ contrib\/solaris\/ contrib\/suse\/ contrib\/hpux\/ contrib\/cygwin\/\n# .\/configure --without-zlib-version-check\n<\/code><\/pre>\n<p>\u203bconfigure\u3068\u306f\u3001OS\u306eCPU\u3084\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u8abf\u3079\u305f\u308a\uff0c\u5fc5\u8981\u306a\u95a2\u9023\u30c4\u30fc\u30eb\u3092\u8abf\u67fb\u3057\u305f\u308a\u3057\u3066\u3001Makefile\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u308b\u3089\u3057\u3044\u30fb\u30fb\u30fb\u8981\u3059\u308b\u306b\u6e96\u5099\u3059\u308b\u546a\u6587\u3089\u3057\u3044\u3002<\/p>\n<p>RPMBUILD\u3067RPM\u30d5\u30a1\u30a4\u30eb\u3092\u751f\u6210\u3059\u308b<\/p>\n<pre><code># cd\n# tar czvf openssh-8.4p1.cust.tar.gz openssh-8.4p1\/\n# rpmbuild --tb --clean openssh-8.4p1.cust.tar.gz\n<\/code><\/pre>\n<p>\u25a0OpenSSH7.6p1\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3061\u3087\u3063\u3068\u305d\u306e\u524d\u306b\u3001SSH\u306e\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u6642\u306bSSH\u63a5\u7d9a\u304c\u5207\u308c\u308b\u554f\u984c\u306e\u89e3\u6d88\u7b56<br \/>\nSSH\u304c\u7acb\u3061\u4e0a\u304c\u3089\u306a\u304f\u306a\u308b\u5bfe\u7b56\u3068\u3057\u3066\u3001\u5225\u9014telnet\u63a5\u7d9a\u304c\u51fa\u6765\u308b\u3088\u3046\u306b\u8a2d\u5b9a\u3057\u3066\u304a\u304d\u3001<br \/>\ntelnet\u3067\u30b5\u30fc\u30d0\u306b\u63a5\u7d9a\u3057\u3001SSH\u3092\u8d77\u52d5\u3055\u305b\u308b\u3068\u3044\u3046\u624b\u9806\u3092\u53d6\u308b\u306e\u3044\u3044\u306e\u3060\u304c\u3001<br \/>\n\u305d\u3046\u3044\u3046\u72b6\u6cc1\u3082\u8a00\u3063\u3066\u3089\u308c\u306a\u3044\u5834\u5408\u3082\u3001\u7279\u306b\u5ba2\u5148\u306e\u30b5\u30fc\u30d0\u3060\u3068\u3002<br \/>\n\u3068\u3044\u3046\u4eba\u306e\u305f\u3081\u306b\u3001SSH\u518d\u8d77\u52d5\u7528\u306eShell\u3092\u4f5c\u3063\u3066\u5bfe\u7b56\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<br \/>\n\u305d\u308c\u3067\u3082SSH\u304c\u8d77\u52d5\u3057\u3066\u3053\u306a\u3044\u5834\u5408\u306f\u3001\u8a2d\u5b9a\u8af8\u3005\u304c\u9593\u9055\u3063\u3066\u3044\u308b\u306e\u3067\u3001<br \/>\n\u3042\u304d\u3089\u3081\u3066\u30b5\u30fc\u30d0\u7ba1\u7406\u8005\u306e\u5354\u529b\u3092\u4ef0\u304e\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre><code># cd\n# vi sshd_start_checker.sh\n<\/code><\/pre>\n<p>\u5185\u5bb9\u306f\u4e0b\u8a18\u3001\u8d77\u52d5\u3057\u3066\u308b\u304b\u30c1\u30a7\u30c3\u30af\u3057\u3066\u8d77\u52d5\u3057\u3066\u3044\u306a\u3044\u5834\u5408\u306f\u3001\u8d77\u52d5\u3059\u308b<\/p>\n<pre><code>#!\/bin\/sh\nCHECK=`systemctl status sshd.service | grep running`\nif [ \"$CHECK\" = \"\" ]; then\n  systemctl start sshd.service\nfi<\/code><\/pre>\n<p>\u4e0a\u8a18\u30b7\u30a7\u30eb\u3092\u3001\u30af\u30fc\u30ed\u30f3\u306b\u57cb\u3081\u30661\u5206\u6bce\u306b\u8d77\u52d5\u3059\u308b<\/p>\n<pre><code># crontab -e\n* * * * * \/root\/sshd_start_checker.sh &gt;\/dev\/null 2&gt;&amp;1\n<\/code><\/pre>\n<p>\u4e0b\u8a18\u30b3\u30de\u30f3\u30c9\u3067\u3001SSH\u6b62\u3081\u3066\u3082\u4e0a\u304c\u3063\u3066\u308b\u304f\u308b\u30c1\u30a7\u30c3\u30af\u3059\u308b<\/p>\n<pre><code># systemctl stop sshd.service\n# systemctl status sshd.service\n<\/code><\/pre>\n<p>\u25a0\u3055\u3063\u305d\u304f\u65e7OpenSSH\u306e\u524a\u9664\u3001\u3055\u3063\u304d\u4f5c\u3063\u305fRPM\u3067\u65b0OpenSSH\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/p>\n<pre><code># cd \/root\/rpmbuild\/RPMS\/x86_64\/\n# ls -la\n\/\/\u203b\u2193\u3053\u3093\u306a\u611f\u3058\u306b\u306a\u3063\u3066\u308b\u306f\u305a\n[root@adan x86_64]# ll\n\u5408\u8a08 1344\n-rw-r--r-- 1 root root 470392  3\u6708  7 15:16 openssh-7.6p1-1.x86_64.rpm\n-rw-r--r-- 1 root root 513756  3\u6708  7 15:16 openssh-clients-7.6p1-1.x86_64.rpm\n-rw-r--r-- 1 root root  16980  3\u6708  7 15:16 openssh-debuginfo-7.6p1-1.x86_64.rpm\n-rw-r--r-- 1 root root 366444  3\u6708  7 15:16 openssh-server-7.6p1-1.x86_64.rpm\n\n\/\/\uff0a\u4e00\u65e6\u53e4\u3044\u3084\u3064\u3092\u524a\u9664\u3057RPM\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\n# yum -y remove openssh\n# rpm -Uvh openssh-7.6p1-1.x86_64.rpm\n# rpm -Uvh openssh-server-7.6p1-1.x86_64.rpm\n# rpm -Uvh openssh-clients-7.6p1-1.x86_64.rpm\n# rpm -Uvh openssh-debuginfo-7.6p1-1.x86_64.rpm \n<\/code><\/pre>\n<p>\u25a0\u518d\u8d77\u52d5\u3057\u3066\u65b0OpenSSH\u306b\u5207\u308a\u66ff\u3048\u308b<\/p>\n<pre><code># systemctl restart sshd.service<\/code><\/pre>\n<p>\u30ed\u30fc\u30ab\u30eb\u304b\u3089\u63a5\u7d9a\u3057\u3066\u307f\u308b<\/p>\n<pre><code>$ ssh yonaha@xxx.xxx.xxx.xxx\nUnable to negotiate with xxx.xxx.xxx.xxx port 22: no matching host key type found. Their offer:\n<\/code><\/pre>\n<p>\u3042\u308c\uff1f\u3064\u306a\u304c\u3089\u306a\u3044\u3002\u3002\u3002<\/p>\n<p>\u72b6\u614b\u3092\u78ba\u8a8d\u3057\u3066\u307f\u308b<\/p>\n<pre><code># systemctl status sshd.service\nerror: Permissions 0640 for '\/etc\/ssh\/ssh_host_ed25519_key' are too open.\n<\/code><\/pre>\n<p>\u3068\u306a\u3063\u3066\u3044\u3066\u3001\u306a\u3093\u3060\u304b\u79d8\u5bc6\u9375\u306e\u30d5\u30a1\u30a4\u30eb\u6a29\u9650\u5468\u308a\u304c\u539f\u56e0\u3089\u3057\u3044\u3002<\/p>\n<p>\u306a\u306e\u3067\u3001\u6a29\u9650\u5468\u308a\u3092600\u306b\u5909\u3048\u3066\u3084\u308b<\/p>\n<pre><code># chmod 600 \/etc\/ssh\/ssh_host_ed25519_key\n# chmod 600 \/etc\/ssh\/ssh_host_ecdsa_key\n# chmod 600 \/etc\/ssh\/ssh_host_rsa_key\n<\/code><\/pre>\n<p>\u518d\u3073\u518d\u6a5f\u52d5<\/p>\n<pre><code># systemctl restart sshd.service<\/code><\/pre>\n<p>\u30ed\u30fc\u30ab\u30eb\u3067\u8a66\u3057\u3066\u307f\u308b\u3068\u7121\u4e8b\u306b\u63a5\u7d9a\u78ba\u8a8d\u304c\u53d6\u308c\u307e\u3057\u305f\u3002<\/p>\n<pre><code># ssh -V\nOpenSSH_8.4p1, OpenSSL 1.0.2k-fips  26 Jan 2017\n<\/code><\/pre>\n<p>\u3068\u308a\u3042\u3048\u305a\u3001\u7121\u4e8b\u7e4b\u304c\u3063\u305f\u306e\u3067OK\u2026\u3060\u304c\u306a\u3093\u3067\u3060\u308d\u3045\u3001\u4eca\u5ea6SSH\u306e\u9375\u8a8d\u8a3c\u5468\u308a\u6697\u53f7\u65b9\u5f0f\u5468\u308a\u3092\u8abf\u3079\u3066\u307f\u307e\u3059\u3002<\/p>\n<hr><div class='adan_banner'>\n<a href='\/contact'><img src='\/blog\/wp-content\/uploads\/2019\/02\/bosyu_banner.jpeg'><\/a>\n<\/div>  <div class=\"sng-box box26\"><div class=\"box-title\">\u30d7\u30ed\u306b\u805e\u3044\u3066\u307f\u308b<\/div><div class=\"box-content\">\u682a\u5f0f\u4f1a\u793eadan\u306f\u30a8\u30f3\u30b8\u30cb\u30a2\u306e\u30ad\u30e3\u30ea\u30a2\u306b\u771f\u5263\u306b\u5411\u304d\u5408\u3063\u3066\u3044\u307e\u3059\u3002<br>\n<strong class='keiko_blue'>\u4f01\u696d\u306e\u60c5\u5831<\/strong>\u3084<strong class='keiko_blue'>\u30a8\u30f3\u30b8\u30cb\u30a2\u3068\u3057\u3066\u306e\u30ad\u30e3\u30ea\u30a2\u30a2\u30c3\u30d7<\/strong>\u306e\u65b9\u6cd5\u3001<strong class='keiko_blue'>\u73fe\u5728\u306e\u5f85\u9047\uff08\u7d66\u6599\u30fb\u5831\u916c\uff09<\/strong>\u3001<strong class='keiko_blue'>\u672a\u7d4c\u9a13\u304b\u3089\u306e\u30b9\u30c6\u30c3\u30d7\u30a2\u30c3\u30d7\u65b9\u6cd5<\/strong>\u306a\u3069\u306e\u3054\u76f8\u8ac7\u3092\u53d7\u3051\u4ed8\u3051\u3066\u3044\u307e\u3059\u3002<br>\n\u304a\u6c17\u8efd\u306b\u304a\u554f\u5408\u305b\u304f\u3060\u3055\u3044\u3002<div class=\"center\"><p>  <a href=\"\/contact\" class=\"btn raised accent-bc strong\">\u304a\u554f\u5408\u305b\u306f\u3053\u3061\u3089<\/a><\/p><\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>\u3055\u304f\u3089\u30af\u30e9\u30a6\u30c9\u3067\u3001CentOS7\u3067Web\u30b5\u30fc\u30d3\u30b9\u3092\u5c55\u958b\u3059\u308b\u969b\u3001\u307e\u305a\u6700\u521d\u306b\u3084\u3063\u3066\u304a\u304d\u305f\u3044\u30a4\u30f3\u30d5\u30e9\u306e\u8a2d\u5b9a\u306e\u4e00\u3064\u306b\u3001OpenSSH\u306e\u66f4\u65b0\u304c\u3042\u308a\u307e\u3059\u3002 \u4eca\u56de\u306f\u3001CentOS7\u306b\u3001\u6700\u65b0\u306eOpenSSH\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u306a\u304a\u3059\u624b\u9806\u3092\u3084 &#8230; <\/p>\n","protected":false},"author":2,"featured_media":1742,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[54],"tags":[],"class_list":{"0":"post-1741","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-programing"},"_links":{"self":[{"href":"https:\/\/adan.jp.net\/blog\/wp-json\/wp\/v2\/posts\/1741","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/adan.jp.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/adan.jp.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/adan.jp.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/adan.jp.net\/blog\/wp-json\/wp\/v2\/comments?post=1741"}],"version-history":[{"count":6,"href":"https:\/\/adan.jp.net\/blog\/wp-json\/wp\/v2\/posts\/1741\/revisions"}],"predecessor-version":[{"id":2895,"href":"https:\/\/adan.jp.net\/blog\/wp-json\/wp\/v2\/posts\/1741\/revisions\/2895"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/adan.jp.net\/blog\/wp-json\/wp\/v2\/media\/1742"}],"wp:attachment":[{"href":"https:\/\/adan.jp.net\/blog\/wp-json\/wp\/v2\/media?parent=1741"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/adan.jp.net\/blog\/wp-json\/wp\/v2\/categories?post=1741"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/adan.jp.net\/blog\/wp-json\/wp\/v2\/tags?post=1741"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}