{"id":1,"date":"2024-05-28T09:49:29","date_gmt":"2024-05-28T09:49:29","guid":{"rendered":"http:\/\/zhaoyanqi.cn\/?p=1"},"modified":"2024-09-20T19:56:44","modified_gmt":"2024-09-20T11:56:44","slug":"hello-world","status":"publish","type":"post","link":"https:\/\/zhaoyanqi.cn\/?p=1","title":{"rendered":"*\u65b0\u5efa\u4e00\u53f0\u670d\u52a1\u5668\u4ee5\u540e\u8981\u505a\u7684\u4e8b\u60c5\uff08\u5b9e\u9a8c\u73af\u5883\uff09"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\" id=\"Q13rm\">1\u3001\u5173\u95ed\u9632\u706b\u5899\u548cselinux<\/h1>\n\n\n\n<p id=\"u524d782d\">\u6c38\u4e45\u5173\u9632\u706b\u5899<\/p>\n\n\n\n<p id=\"u3a500266\">iptables -t filter -F<\/p>\n\n\n\n<p id=\"udfd130f5\">systemctl stop firewalld<\/p>\n\n\n\n<p id=\"u761f06b7\">systemctl disable firewalld<\/p>\n\n\n\n<p id=\"u1aee1671\">systemctl staus firewalld<\/p>\n\n\n\n<p id=\"u22fcdf41\">\u6c38\u4e45\u5173selinux<\/p>\n\n\n\n<p id=\"u0dd97bd6\">vi \/etc\/selinux\/config<\/p>\n\n\n\n<p id=\"uf6cdaf9e\">\u628aSELINUX=enforcing\u6539\u6210disabled<\/p>\n\n\n\n<p id=\"u7a85731a\">\u6216\u7528\u8fd9\u4e2a\u547d\u4ee4\uff1ased -ri &#8216;s\/enforcing\/disabled\/g&#8217; \/etc\/sysconfig\/selinux<\/p>\n\n\n\n<p id=\"uebdad04a\">setenforce 0<\/p>\n\n\n\n<p id=\"u8b85cc45\">\u6216\u8005\u914d\u7f6e\u4e34\u65f6\u5173\u95edselinux<\/p>\n\n\n\n<p id=\"u3896dc29\">setenforce 0<\/p>\n\n\n\n<p id=\"uae23c3a0\">\u7136\u540e\u8bbe\u7f6e\u5f00\u673a\u6302\u8f7d\uff0crc.local\u6216\u8005\/etc\/fstab\u90fd\u53ef\u4ee5\uff0c\u53ef\u4ee5\u7528mount -a\u547d\u4ee4\u9a8c\u8bc1<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>iptables -t filter -F\nsystemctl stop firewalld\nsystemctl disable firewalld\nsystemctl status firewalld\nsed -ri 's\/enforcing\/disabled\/g' \/etc\/sysconfig\/selinux\nsetenforce 0\n\n<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"tHAIM\">2\u3001\u6539\u4e3b\u673a\u540d<\/h1>\n\n\n\n<pre class=\"wp-block-code\"><code>hostnamectl set-hostname xxxxxx \nhostname \ncat \/etc\/hostname\n<\/code><\/pre>\n\n\n\n<p id=\"ufea5cded\"><\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"OdJGY\">3\u3001\u8bbe\u7f6e\u9759\u6001IP<\/h1>\n\n\n\n<p id=\"u09d7c969\"><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>nmcli con mod ens33 ipv4.addresses \"192.168.1.100\/24\"<br>nmcli con mod ens33 ipv4.gateway \"192.168.1.1\"<br>nmcli con mod ens33 ipv4.dns \"8.8.8.8,8.8.4.4\" # \u591a\u4e2adns<br>nmcli con mod ens33 ipv4.method manual<br>nmcli con down ens33\uff1bnmcli con up ens33<\/code><\/pre>\n\n\n\n<p id=\"u09d7c969\"><\/p>\n\n\n\n<p id=\"u09d7c969\"><\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"Z11W3\">4\u3001\u914d\u7f6e\u540c\u6b65\u65f6\u95f4NTP<\/h1>\n\n\n\n<p id=\"uc25bc061\">\u4e0b\u8ff0\u6b65\u9aa4\u4e00\u6b21\u6027\u7c98\u8d34\u5230\u6bcf\u4e2a\u5ba2\u6237\u7aef\u6267\u884c\u5373\u53ef<\/p>\n\n\n\n<pre id=\"SflDP\" class=\"wp-block-code\"><code># 1\u3001\u5b89\u88c5chrony\nyum -y install chrony\n# 2\u3001\u9700\u6539\u5ba2\u6237\u7aef\u914d\u7f6e\u6587\u4ef6\nmv \/etc\/chrony.conf \/etc\/chrony.conf.bak\ncat &gt; \/etc\/chrony.conf &lt;&lt; EOF\nserver ntp1.aliyun.com iburst minpoll 4 maxpoll 10\nserver ntp2.aliyun.com iburst minpoll 4 maxpoll 10\nserver ntp3.aliyun.com iburst minpoll 4 maxpoll 10\nserver ntp4.aliyun.com iburst minpoll 4 maxpoll 10\nserver ntp5.aliyun.com iburst minpoll 4 maxpoll 10\nserver ntp6.aliyun.com iburst minpoll 4 maxpoll 10\nserver ntp7.aliyun.com iburst minpoll 4 maxpoll 10\ndriftfile \/var\/lib\/chrony\/drift\nmakestep 10 3\nrtcsync\nlocal stratum 10\nkeyfile \/etc\/chrony.key\nlogdir \/var\/log\/chrony\nstratumweight 0.05\nnoclientlog\nlogchange 0.5\n \nEOF\n# 3\u3001\u542f\u52a8chronyd\nsystemctl restart chronyd.service\nsystemctl enable chronyd.service\nsystemctl status chronyd.service\n \n# 4\u3001\u9a8c\u8bc1\nchronyc sources -v  # \u7ed3\u679c\u89e3\u6790\u5982\u4e0b\u56fe<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"kDb5D\">5\u3001\u66f4\u65b0\u6e90<\/h1>\n\n\n\n<pre class=\"wp-block-code\"><code>#\u6362\u963f\u91cc\u6e90 \nmv \/etc\/yum.repos.d\/CentOS-Base.repo \/etc\/yum.repos.d\/CentOS-Base.repo.backup \ncurl -o \/etc\/yum.repos.d\/CentOS-Base.repo https:\/\/mirrors.aliyun.com\/repo\/Centos-7.repo \n#\u52a0epel\u6e90 \ncurl -o \/etc\/yum.repos.d\/epel.repo http:\/\/mirrors.aliyun.com\/repo\/epel-7.repo \n#\u66f4\u65b0\u6e90 \nyum upgrade -y \n# \u5bf9\u4e8eDebian\/Ubuntu \nsudo apt update &amp;&amp; sudo apt upgrade -y<\/code><\/pre>\n\n\n\n<p id=\"ud9bf4571\"><\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"tgfBk\">6\u3001\u521b\u5efa\u5bc6\u94a5\u5bf9<\/h1>\n\n\n\n<p id=\"ub4c73344\">\u5047\u8bbe\u73b0\u5728\u65b0\u5efa\u7684\u662f\u4e3b\u673aB\uff0c\u6211\u4eec\u9700\u8981\u4ece\u4e3b\u673aA\u8bbf\u95ee\u4e3b\u673aB<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"xEaJO\">1. \u5728\u4e3b\u673aA\u4e0a\u751f\u6210\u5bc6\u94a5\u5bf9<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code><code>ssh-keygen<\/code><\/code><\/pre>\n\n\n\n<p id=\"ud52e4419\">\u751f\u6210\u7684\u5bc6\u94a5\u5bf9\u5305\u62ec\u516c\u94a5\uff08<strong>~\/.ssh\/id_rsa.pub<\/strong>\uff09\u548c\u79c1\u94a5\uff08<strong>~\/.ssh\/id_rsa<\/strong>\uff09<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"QOnq3\">2. \u5c06\u516c\u94a5\u4ece\u4e3b\u673aA\u590d\u5236\u5230\u4e3b\u673aB<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code><code>ssh-copy-id user@host_b<\/code><\/code><\/pre>\n\n\n\n<p id=\"u59abca23\">\u8fd9\u91cc\u7684<strong>user<\/strong>\u662f\u4e3b\u673aB\u4e0a\u7684\u7528\u6237\u540d\uff0c<strong>host_b<\/strong>\u662f\u4e3b\u673aB\u7684IP\u5730\u5740\u6216\u57df\u540d\u3002\u8fd9\u4e2a\u547d\u4ee4\u4f1a\u63d0\u793a\u4f60\u8f93\u5165\u4e3b\u673aB\u7684\u5bc6\u7801\uff0c\u5e76\u81ea\u52a8\u5c06\u516c\u94a5\u6dfb\u52a0\u5230\u4e3b\u673aB\u7684<strong>~\/.ssh\/authorized_keys<\/strong>\u6587\u4ef6\u4e2d\u3002<\/p>\n\n\n\n<p id=\"u8f1aee27\">\u4e5f\u53ef\u4ee5\u624b\u52a8\u590d\u5236\u516c\u94a5\u3002<\/p>\n\n\n\n<p id=\"u2e16f29f\">\u5728\u4e3b\u673aA\u4e0a\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u5c06\u516c\u94a5\u590d\u5236\u5230\u526a\u8d34\u677f\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat ~\/.ssh\/id_rsa.pub<br>echo \"\u590d\u5236\u7684\u516c\u94a5key\u4e00\u4e32\u82f1\u6587\" &gt;&gt; ~\/.ssh\/authorized_keys<br><br><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"lYsqh\">3. \u8bbe\u7f6e\u4e3b\u673aB\u7684SSH\u914d\u7f6e<\/h3>\n\n\n\n<p id=\"u7fd1441b\"><strong>\u786e\u4fdd<\/strong><strong>~\/.ssh<\/strong><strong>\u76ee\u5f55\u548c<\/strong><strong>authorized_keys<\/strong><strong>\u6587\u4ef6\u7684\u6743\u9650\u6b63\u786e<\/strong>\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>chmod 700 ~\/.ssh<\/code><\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code><code>chmod 600 ~\/.ssh\/authorized_keys<\/code><\/code><\/pre>\n\n\n\n<p id=\"ud3a554cf\"><strong>\u7f16\u8f91<\/strong><strong>\/etc\/ssh\/sshd_config<\/strong><strong>\u6587\u4ef6<\/strong>\uff08\u53ef\u9009\uff0c\u4f46\u63a8\u8350\u68c0\u67e5\uff09\uff0c\u786e\u4fdd\u4ee5\u4e0b\u53c2\u6570\u88ab\u6b63\u786e\u8bbe\u7f6e\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PubkeyAuthentication yes<br>AuthorizedKeysFile .ssh\/authorized_keys<\/code><\/pre>\n\n\n\n<p id=\"ue82f2dbe\"><\/p>\n\n\n\n<p id=\"ue0934f9a\"><strong>\u91cd\u65b0\u542f\u52a8SSH\u670d\u52a1<\/strong>\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>sudo systemctl restart sshd<\/code><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"A8i9W\">4. \u4ece\u4e3b\u673aA\u8fde\u63a5\u5230\u4e3b\u673aB<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code><code>ssh user@host_b<\/code><\/code><\/pre>\n\n\n\n<p id=\"ueed5c926\">\u8fd9\u6837\uff0c\u4f60\u5c31\u5e94\u8be5\u53ef\u4ee5\u6210\u529f\u4f7f\u7528SSH\u5bc6\u94a5\u5bf9\u4ece\u4e3b\u673aA\u8bbf\u95ee\u4e3b\u673aB\u4e86\u3002\u5982\u679c\u9047\u5230\u95ee\u9898\uff0c\u53ef\u4ee5\u68c0\u67e5SSH\u8fde\u63a5\u7684\u8be6\u7ec6\u8f93\u51fa\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>ssh -v user@host_b<\/code><\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001\u5173\u95ed\u9632\u706b\u5899\u548cselinux \u6c38\u4e45\u5173\u9632\u706b\u5899 iptables -t filter -F systemctl  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[11],"class_list":["post-1","post","type-post","status-publish","format-standard","hentry","category-3","tag-frequently_used_blogs"],"_links":{"self":[{"href":"https:\/\/zhaoyanqi.cn\/index.php?rest_route=\/wp\/v2\/posts\/1","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zhaoyanqi.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zhaoyanqi.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zhaoyanqi.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zhaoyanqi.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1"}],"version-history":[{"count":11,"href":"https:\/\/zhaoyanqi.cn\/index.php?rest_route=\/wp\/v2\/posts\/1\/revisions"}],"predecessor-version":[{"id":321,"href":"https:\/\/zhaoyanqi.cn\/index.php?rest_route=\/wp\/v2\/posts\/1\/revisions\/321"}],"wp:attachment":[{"href":"https:\/\/zhaoyanqi.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zhaoyanqi.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zhaoyanqi.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}