{"id":47976,"date":"2025-07-30T10:12:46","date_gmt":"2025-07-30T02:12:46","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/47976.html"},"modified":"2025-07-30T10:12:46","modified_gmt":"2025-07-30T02:12:46","slug":"linux-%e6%9c%8d%e5%8a%a1%e5%99%a8%e5%91%bd%e4%bb%a4%e5%ae%a1%e8%ae%a1%ef%bc%9a%e8%ae%b0%e5%bd%95-ssh-%e5%91%bd%e4%bb%a4%e5%b9%b6%e5%ae%9e%e7%8e%b0%e6%8c%89%e5%a4%a9%e8%bd%ae%e8%bd%ac","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/47976.html","title":{"rendered":"Linux \u670d\u52a1\u5668\u547d\u4ee4\u5ba1\u8ba1\uff1a\u8bb0\u5f55 SSH \u547d\u4ee4\u5e76\u5b9e\u73b0\u6309\u5929\u8f6e\u8f6c"},"content":{"rendered":"<h3>\u8def\u867d\u5f25,\u4e0d\u884c\u4e0d\u81f3&#xff1b;\u4e8b\u867d\u5c0f,\u4e0d\u505a\u4e0d\u6210<\/h3>\n<h3>\u6458\u8981<\/h3>\n<p>\u672c\u6587\u4ecb\u7ecd\u5982\u4f55\u5728 Linux \u670d\u52a1\u5668&#xff08;\u4ee5 CentOS 7.9 \u4e3a\u4f8b&#xff09;\u4e0a\u5b9e\u73b0 SSH \u547d\u4ee4\u5ba1\u8ba1&#xff0c;\u901a\u8fc7 Bash \u811a\u672c\u8bb0\u5f55\u7528\u6237\u6267\u884c\u7684\u547d\u4ee4\u5230\u6307\u5b9a\u65e5\u5fd7\u6587\u4ef6&#xff0c;\u5e76\u4f7f\u7528 logrotate \u5b9e\u73b0\u6309\u5929\u8f6e\u8f6c\u3002\u5de5\u5177\u9002\u7528\u4e8e\u8fd0\u7ef4\u4eba\u5458\u548c\u7cfb\u7edf\u7ba1\u7406\u5458&#xff0c;\u80fd\u591f\u76d1\u63a7\u7528\u6237\u64cd\u4f5c\u3001\u4fbf\u4e8e\u5ba1\u8ba1\u548c\u95ee\u9898\u6392\u67e5\u3002\u65e5\u5fd7\u6587\u4ef6\u6743\u9650\u8bbe\u7f6e\u4e3a 666&#xff0c;\u4ee5\u652f\u6301\u591a\u7528\u6237\u5199\u5165&#xff0c;\u9002\u5408\u6d4b\u8bd5\u6216\u53d7\u63a7\u73af\u5883\u3002\u914d\u7f6e\u7b80\u5355&#xff0c;\u4ee3\u7801\u53ef\u4e00\u952e\u590d\u5236\u3002<\/p>\n<h3>\u524d\u7f6e\u6761\u4ef6<\/h3>\n<ul>\n<li>\u7cfb\u7edf&#xff1a;CentOS 7.9 \u6216\u5176\u4ed6\u652f\u6301 Bash \u548c logrotate \u7684 Linux \u7cfb\u7edf<\/li>\n<li>\u6743\u9650&#xff1a;root \u7528\u6237\u6216\u5177\u6709 sudo \u6743\u9650<\/li>\n<li>\u73af\u5883&#xff1a;\u5df2\u542f\u7528 SSH \u670d\u52a1&#xff0c;\u5177\u5907 Bash \u73af\u5883<\/li>\n<li>\u5de5\u5177&#xff1a;\u786e\u4fdd logrotate \u5df2\u5b89\u88c5&#xff08;\u9ed8\u8ba4\u5305\u542b\u5728 CentOS \u4e2d&#xff09;<\/li>\n<\/ul>\n<hr \/>\n<h3>\u4e00\u3001\u521b\u5efa\u65e5\u5fd7\u6587\u4ef6\u5e76\u8bbe\u7f6e\u6743\u9650<\/h3>\n<p>\u521b\u5efa\u7528\u4e8e\u5b58\u50a8 SSH \u547d\u4ee4\u7684\u65e5\u5fd7\u6587\u4ef6&#xff0c;\u5e76\u8bbe\u7f6e\u6743\u9650\u4e3a 666&#xff0c;\u5141\u8bb8\u6240\u6709\u7528\u6237\u5199\u5165\u3002<\/p>\n<p><span class=\"token comment\"># \u521b\u5efa\u65e5\u5fd7\u6587\u4ef6<\/span><br \/>\n<span class=\"token function\">sudo<\/span> <span class=\"token function\">touch<\/span> \/var\/log\/ssh_command.log<br \/>\n<span class=\"token comment\"># \u8bbe\u7f6e\u6743\u9650\u4e3a 666&#xff0c;\u786e\u4fdd\u6240\u6709\u7528\u6237\u53ef\u5199\u5165<\/span><br \/>\n<span class=\"token function\">sudo<\/span> <span class=\"token function\">chmod<\/span> <span class=\"token number\">666<\/span> \/var\/log\/ssh_command.log<br \/>\n<span class=\"token comment\"># \u8bbe\u7f6e\u6587\u4ef6\u5f52\u5c5e\u4e3a root:root<\/span><br \/>\n<span class=\"token function\">sudo<\/span> <span class=\"token function\">chown<\/span> root:root \/var\/log\/ssh_command.log<\/p>\n<p>\u5b89\u5168\u63d0\u793a&#xff1a;\u6743\u9650 666 \u5141\u8bb8\u4efb\u610f\u7528\u6237\u8bfb\u5199\u65e5\u5fd7\u6587\u4ef6&#xff0c;\u9002\u5408\u6d4b\u8bd5\u6216\u53d7\u63a7\u73af\u5883\u3002\u5728\u751f\u4ea7\u73af\u5883\u4e2d&#xff0c;\u5efa\u8bae\u5c06\u65e5\u5fd7\u6587\u4ef6\u653e\u5165\u53d7\u9650\u76ee\u5f55&#xff08;\u5982 \/var\/log\/audit\/&#xff0c;\u76ee\u5f55\u6743\u9650\u4e3a 750&#xff09;&#xff0c;\u6216\u4f7f\u7528 660 \u6743\u9650\u5e76\u5c06\u7528\u6237\u52a0\u5165\u7279\u5b9a\u7ec4&#xff08;\u5982 adm&#xff09;\u3002<\/p>\n<hr \/>\n<h3>\u4e8c\u3001\u521b\u5efa\u547d\u4ee4\u8bb0\u5f55\u811a\u672c<\/h3>\n<p>\u5728 \/etc\/profile.d\/ \u4e0b\u521b\u5efa\u811a\u672c&#xff0c;\u6355\u83b7\u5e76\u8bb0\u5f55 SSH \u547d\u4ee4\u3002<\/p>\n<p><span class=\"token comment\"># \u521b\u5efa\u811a\u672c<\/span><br \/>\n<span class=\"token function\">cat<\/span> <span class=\"token operator\">&lt;&lt;<\/span><span class=\"token string\">EOF<span class=\"token bash punctuation\"> <span class=\"token operator\">&gt;<\/span> \/etc\/profile.d\/command_log.sh<\/span><br \/>\n#!\/bin\/bash<br \/>\nlog_command() {<br \/>\n  # \u8df3\u8fc7\u7a7a\u547d\u4ee4\u6216\u65e0\u5173\u547d\u4ee4&#xff08;\u5982 PS1\u3001PS2 \u7b49&#xff09;<br \/>\n  if [[ -z &#034;\\\\<span class=\"token variable\">$BASH_COMMAND<\/span>&#034; || &#034;\\\\<span class=\"token variable\">$BASH_COMMAND<\/span>&#034; &#061;~ ^(printf<span class=\"token entity\" title=\"\\\\\\\\\">\\\\\\\\<\/span> <span class=\"token entity\" title=\"\\\\&#034;\">\\\\&#034;<\/span><span class=\"token entity\" title=\"\\\\\\\\\">\\\\\\\\<\/span>033|PS1&#061;|PS2&#061;|PS4&#061;|trap<span class=\"token entity\" title=\"\\\\\\\\\">\\\\\\\\<\/span> ) ]]; then<br \/>\n    return 0<br \/>\n  fi<\/p>\n<p>  # \u4ec5\u5728\u4ea4\u4e92\u5f0f shell \u4e2d\u8bb0\u5f55<br \/>\n  if [[ &#034;\\\\$-&#034; !&#061; *i* ]]; then<br \/>\n    return 0<br \/>\n  fi<\/p>\n<p>  # \u83b7\u53d6\u5ba2\u6237\u7aef IP \u548c\u7aef\u53e3&#xff0c;\u5904\u7406 SSH_CLIENT \u672a\u5b9a\u4e49\u7684\u60c5\u51b5<br \/>\n  if [[ -n &#034;\\\\<span class=\"token variable\">$SSH_CLIENT<\/span>&#034; ]]; then<br \/>\n    client_ip&#061;\\\\<span class=\"token variable\"><span class=\"token variable\">$(<\/span><span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#034;\\\\<span class=\"token variable\">$SSH_CLIENT<\/span>&#034;<\/span> <span class=\"token operator\">|<\/span> <span class=\"token function\">awk<\/span> <span class=\"token string\">&#039;{print \\\\<span class=\"token variable\">$1<\/span>}&#039;<\/span> <span class=\"token operator\">||<\/span> <span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#034;UNKNOWN&#034;<\/span><span class=\"token variable\">)<\/span><\/span><br \/>\n    client_port&#061;\\\\<span class=\"token variable\"><span class=\"token variable\">$(<\/span><span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#034;\\\\<span class=\"token variable\">$SSH_CLIENT<\/span>&#034;<\/span> <span class=\"token operator\">|<\/span> <span class=\"token function\">awk<\/span> <span class=\"token string\">&#039;{print \\\\<span class=\"token variable\">$2<\/span>}&#039;<\/span> <span class=\"token operator\">||<\/span> <span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#034;-&#034;<\/span><span class=\"token variable\">)<\/span><\/span><br \/>\n  else<br \/>\n    client_ip&#061;&#034;LOCAL&#034;<br \/>\n    client_port&#061;&#034;-&#034;<br \/>\n  fi<\/p>\n<p>  # \u8bb0\u5f55\u547d\u4ee4\u5230\u65e5\u5fd7\u6587\u4ef6<br \/>\n  log_file&#061;&#034;\/var\/log\/ssh_command.log&#034;<br \/>\n  echo &#034;[ \\\\<span class=\"token variable\"><span class=\"token variable\">$(<\/span><span class=\"token function\">date<\/span> <span class=\"token string\">&#039;&#043;%F %T&#039;<\/span><span class=\"token variable\">)<\/span><\/span> \\\\<span class=\"token variable\">$client_ip<\/span> \\\\<span class=\"token variable\">$client_port<\/span> \\\\<span class=\"token variable\"><span class=\"token variable\">$(<\/span><span class=\"token function\">whoami<\/span><span class=\"token variable\">)<\/span><\/span> ] \\\\<span class=\"token variable\">$BASH_COMMAND<\/span>&#034; &gt;&gt; &#034;\\\\<span class=\"token variable\">$log_file<\/span>&#034;<br \/>\n}<\/p>\n<p># \u8bbe\u7f6e DEBUG \u9677\u9631\u6355\u83b7\u547d\u4ee4<br \/>\ntrap log_command DEBUG<br \/>\nEOF<\/span><\/p>\n<p><span class=\"token comment\"># \u8bbe\u7f6e\u811a\u672c\u6267\u884c\u6743\u9650<\/span><br \/>\n<span class=\"token function\">chmod<\/span> &#043;x \/etc\/profile.d\/command_log.sh<\/p>\n<p>\u65e5\u5fd7\u683c\u5f0f\u8bf4\u660e&#xff1a;<br \/>\n\u65e5\u5fd7\u6587\u4ef6 \/var\/log\/ssh_command.log \u7684\u8bb0\u5f55\u683c\u5f0f\u5982\u4e0b&#xff1a;<\/p>\n<p>[ 2025-05-21 15:45:05 192.168.10.1 61275 root ] ps aux<\/p>\n<ul>\n<li>\u5305\u542b\u65f6\u95f4\u6233\u3001\u5ba2\u6237\u7aef IP\u3001\u7aef\u53e3\u3001\u7528\u6237\u540d\u548c\u6267\u884c\u7684\u547d\u4ee4\u3002<\/li>\n<\/ul>\n<p>\u6ce8\u610f&#xff1a;<\/p>\n<ul>\n<li>\u811a\u672c\u901a\u8fc7 \/etc\/profile.d\/ \u52a0\u8f7d&#xff0c;\u9002\u7528\u4e8e\u6240\u6709 Bash \u7528\u6237\u3002\u65b0\u767b\u5f55\u7684\u4f1a\u8bdd\u4f1a\u81ea\u52a8\u5e94\u7528\u811a\u672c\u3002<\/li>\n<li>\u5df2\u6dfb\u52a0\u7a7a\u547d\u4ee4\u68c0\u67e5\u548c SSH_CLIENT  \u0c2a<\/li>\n<\/ul>\n<hr \/>\n<h3>\u4e09\u3001\u914d\u7f6e\u65e5\u5fd7\u8f6e\u8f6c<\/h3>\n<p>\u4f7f\u7528 logrotate \u5b9e\u73b0\u65e5\u5fd7\u6587\u4ef6\u7684\u6309\u5929\u8f6e\u8f6c&#xff0c;\u9632\u6b62\u6587\u4ef6\u8fc7\u5927\u3002<\/p>\n<p><span class=\"token comment\"># \u521b\u5efa\u8f6e\u8f6c\u914d\u7f6e\u6587\u4ef6<\/span><br \/>\n<span class=\"token function\">cat<\/span> <span class=\"token operator\">&lt;&lt;<\/span><span class=\"token string\">EOF<span class=\"token bash punctuation\"> <span class=\"token operator\">&gt;<\/span> \/etc\/logrotate.d\/ssh_command<\/span><br \/>\n\/var\/log\/ssh_command.log {<br \/>\n    daily<br \/>\n    rotate 7<br \/>\n    compress<br \/>\n    missingok<br \/>\n    notifempty<br \/>\n    copytruncate<br \/>\n    dateext<br \/>\n    dateformat -%Y%m%d<br \/>\n    create 0666 root root<br \/>\n    maxsize 100M<br \/>\n}<br \/>\nEOF<\/span><\/p>\n<p><span class=\"token comment\"># \u68c0\u67e5\u914d\u7f6e\u6587\u4ef6\u8bed\u6cd5<\/span><br \/>\n<span class=\"token function\">logrotate<\/span> -d \/etc\/logrotate.d\/ssh_command<\/p>\n<p>\u914d\u7f6e\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>daily&#xff1a;\u6309\u5929\u8f6e\u8f6c\u3002<\/li>\n<li>rotate 7&#xff1a;\u4fdd\u7559 7 \u5929\u7684\u65e5\u5fd7\u3002<\/li>\n<li>compress&#xff1a;\u538b\u7f29\u65e7\u65e5\u5fd7\u6587\u4ef6\u3002<\/li>\n<li>missingok&#xff1a;\u5ffd\u7565\u65e5\u5fd7\u6587\u4ef6\u7f3a\u5931\u7684\u9519\u8bef\u3002<\/li>\n<li>notifempty&#xff1a;\u4e0d\u8f6e\u8f6c\u7a7a\u6587\u4ef6\u3002<\/li>\n<li>copytruncate&#xff1a;\u590d\u5236\u5e76\u622a\u65ad\u65e5\u5fd7\u6587\u4ef6&#xff0c;\u907f\u514d\u4e2d\u65ad\u5199\u5165\u3002<\/li>\n<li>dateext \u548c dateformat&#xff1a;\u8f6e\u8f6c\u6587\u4ef6\u4ee5\u65e5\u671f\u547d\u540d&#xff08;\u5982 ssh_command.log-20250521&#xff09;\u3002<\/li>\n<li>create 0666 root root&#xff1a;\u8f6e\u8f6c\u540e\u521b\u5efa\u65b0\u6587\u4ef6&#xff0c;\u6743\u9650\u4e3a 666\u3002<\/li>\n<li>maxsize 100M&#xff1a;\u5355\u65e5\u65e5\u5fd7\u8d85\u8fc7 100MB \u65f6\u89e6\u53d1\u8f6e\u8f6c\u3002<\/li>\n<\/ul>\n<p>\u6d4b\u8bd5\u8f6e\u8f6c&#xff1a;<\/p>\n<p><span class=\"token comment\"># \u8c03\u8bd5\u8f6e\u8f6c&#xff08;\u4e0d\u4f1a\u5b9e\u9645\u6267\u884c&#xff09;<\/span><br \/>\n<span class=\"token function\">logrotate<\/span> -d \/etc\/logrotate.d\/ssh_command<br \/>\n<span class=\"token comment\"># \u5f3a\u5236\u6267\u884c\u8f6e\u8f6c<\/span><br \/>\n<span class=\"token function\">logrotate<\/span> -f \/etc\/logrotate.d\/ssh_command<\/p>\n<hr \/>\n<h3>\u56db\u3001\u9a8c\u8bc1\u4e0e\u6392\u67e5<\/h3>\n<h4>4.1 \u9a8c\u8bc1\u65e5\u5fd7\u8bb0\u5f55<\/h4>\n<p>\u6267\u884c\u4efb\u610f\u547d\u4ee4&#xff08;\u5982 ls&#xff09;&#xff0c;\u7136\u540e\u68c0\u67e5\u65e5\u5fd7\u6587\u4ef6&#xff1a;<\/p>\n<p><span class=\"token function\">cat<\/span> \/var\/log\/ssh_command.log<\/p>\n<p>\u786e\u8ba4\u662f\u5426\u8bb0\u5f55\u4e86\u7c7b\u4f3c\u4ee5\u4e0b\u5185\u5bb9&#xff1a;<\/p>\n<p>[ 2025-05-21 15:45:05 192.168.10.1 61275 root ] ls<\/p>\n<h4>4.2 \u5e38\u89c1\u95ee\u9898\u6392\u67e5<\/h4>\n<ul>\n<li>\n<p>\u65e5\u5fd7\u672a\u8bb0\u5f55<\/p>\n<p>&#xff1a;<\/p>\n<ul>\n<li>\u68c0\u67e5 \/etc\/profile.d\/command_log.sh \u662f\u5426\u6709\u6267\u884c\u6743\u9650&#xff08;chmod &#043;x&#xff09;\u3002<\/li>\n<li>\u786e\u8ba4\u662f\u5426\u4ee5 Bash \u767b\u5f55&#xff08;echo $SHELL \u5e94\u4e3a \/bin\/bash&#xff09;\u3002<\/li>\n<li>\u65b0\u4f1a\u8bdd\u672a\u52a0\u8f7d\u811a\u672c&#xff0c;\u53ef\u6267\u884c source \/etc\/profile.d\/command_log.sh\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u8f6e\u8f6c\u5931\u8d25<\/p>\n<p>&#xff1a;<\/p>\n<ul>\n<li>\u68c0\u67e5 \/etc\/logrotate.d\/ssh_command \u8bed\u6cd5&#xff1a;logrotate -d \/etc\/logrotate.d\/ssh_command\u3002<\/li>\n<li>\u786e\u4fdd logrotate \u670d\u52a1\u6b63\u5e38\u8fd0\u884c&#xff08;\u901a\u5e38\u7531 cron \u5b9a\u65f6\u6267\u884c&#xff09;\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u6743\u9650\u9519\u8bef<\/p>\n<p>&#xff1a;<\/p>\n<ul>\n<li>\u786e\u8ba4 \/var\/log\/ssh_command.log \u6743\u9650\u4e3a 666&#xff0c;\u5f52\u5c5e\u4e3a root:root\u3002<\/li>\n<li>\u82e5\u975e root \u7528\u6237\u65e0\u6cd5\u5199\u5165&#xff0c;\u68c0\u67e5\u662f\u5426\u8bef\u5c06\u6743\u9650\u8bbe\u4e3a 644 \u6216 600\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<hr \/>\n<h3>\u4e94\u3001\u603b\u7ed3<\/h3>\n<p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4&#xff0c;\u4f60\u5df2\u6210\u529f\u5728 Linux \u670d\u52a1\u5668\u4e0a\u5b9e\u73b0 SSH \u547d\u4ee4\u5ba1\u8ba1\u548c\u65e5\u5fd7\u8f6e\u8f6c\u529f\u80fd\u3002\u8be5\u5de5\u5177\u8f7b\u91cf\u9ad8\u6548&#xff0c;\u9002\u5408\u4f01\u4e1a\u7ea7\u670d\u52a1\u5668\u7684\u8fd0\u7ef4\u5ba1\u8ba1\u573a\u666f\u3002\u540e\u7eed\u53ef\u6269\u5c55\u529f\u80fd&#xff0c;\u5982\u5c06\u65e5\u5fd7\u63a8\u9001\u5230\u8fdc\u7a0b\u670d\u52a1\u5668\u3002<\/p>\n<p>\u6b22\u8fce\u5728\u8bc4\u8bba\u533a\u5206\u4eab\u4f60\u7684\u4f7f\u7528\u7ecf\u9a8c\u6216\u95ee\u9898&#xff0c;\u6211\u4eec\u4e00\u8d77\u63a2\u8ba8&#xff01;<\/p>\n<p>\u58f0\u660e&#xff1a;\u672c\u4eba\u539f\u521b&#xff0c;\u6b22\u8fce\u8f6c\u8f7d&#xff0c;\u8bf7\u6ce8\u660e\u51fa\u5904\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1k\u6b21\uff0c\u70b9\u8d5e29\u6b21\uff0c\u6536\u85cf7\u6b21\u3002\u672c\u6587\u4ecb\u7ecd\u5982\u4f55\u5728 Linux \u670d\u52a1\u5668\uff08\u4ee5 CentOS 7.9 \u4e3a\u4f8b\uff09\u4e0a\u5b9e\u73b0 SSH \u547d\u4ee4\u5ba1\u8ba1\uff0c\u901a\u8fc7 Bash \u811a\u672c\u8bb0\u5f55\u7528\u6237\u6267\u884c\u7684\u547d\u4ee4\u5230\u6307\u5b9a\u65e5\u5fd7\u6587\u4ef6\uff0c\u5e76\u4f7f\u7528logrotate\u5b9e\u73b0\u6309\u5929\u8f6e\u8f6c\u3002\u5de5\u5177\u9002\u7528\u4e8e\u8fd0\u7ef4\u4eba\u5458\u548c\u7cfb\u7edf\u7ba1\u7406\u5458\uff0c\u80fd\u591f\u76d1\u63a7\u7528\u6237\u64cd\u4f5c\u3001\u4fbf\u4e8e\u5ba1\u8ba1\u548c\u95ee\u9898\u6392\u67e5\u3002\u65e5\u5fd7\u6587\u4ef6\u6743\u9650\u8bbe\u7f6e\u4e3a666\uff0c\u4ee5\u652f\u6301\u591a\u7528\u6237\u5199\u5165\uff0c\u9002\u5408\u6d4b\u8bd5\u6216\u53d7\u63a7\u73af\u5883\u3002\u914d\u7f6e\u7b80\u5355\uff0c\u4ee3\u7801\u53ef\u4e00\u952e\u590d\u5236\u3002\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u4f60\u5df2\u6210\u529f\u5728 Linux \u670d\u52a1\u5668\u4e0a\u5b9e\u73b0 SSH \u547d\u4ee4\u5ba1\u8ba1\u548c\u65e5\u5fd7\u8f6e\u8f6c\u529f\u80fd\u3002\u8be5\u5de5\u5177\u8f7b\u91cf\u9ad8\u6548\uff0c\u9002\u5408\u4f01\u4e1a\u7ea7\u670d\u52a1\u5668\u7684\u8fd0\u7ef4\u5ba1\u8ba1\u573a\u666f\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[59,58,77,43],"topic":[],"class_list":["post-47976","post","type-post","status-publish","format-standard","hentry","category-server","tag-centos","tag-linux","tag-ssh","tag-43"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Linux \u670d\u52a1\u5668\u547d\u4ee4\u5ba1\u8ba1\uff1a\u8bb0\u5f55 SSH \u547d\u4ee4\u5e76\u5b9e\u73b0\u6309\u5929\u8f6e\u8f6c - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/47976.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Linux \u670d\u52a1\u5668\u547d\u4ee4\u5ba1\u8ba1\uff1a\u8bb0\u5f55 SSH \u547d\u4ee4\u5e76\u5b9e\u73b0\u6309\u5929\u8f6e\u8f6c - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1k\u6b21\uff0c\u70b9\u8d5e29\u6b21\uff0c\u6536\u85cf7\u6b21\u3002\u672c\u6587\u4ecb\u7ecd\u5982\u4f55\u5728 Linux \u670d\u52a1\u5668\uff08\u4ee5 CentOS 7.9 \u4e3a\u4f8b\uff09\u4e0a\u5b9e\u73b0 SSH \u547d\u4ee4\u5ba1\u8ba1\uff0c\u901a\u8fc7 Bash \u811a\u672c\u8bb0\u5f55\u7528\u6237\u6267\u884c\u7684\u547d\u4ee4\u5230\u6307\u5b9a\u65e5\u5fd7\u6587\u4ef6\uff0c\u5e76\u4f7f\u7528logrotate\u5b9e\u73b0\u6309\u5929\u8f6e\u8f6c\u3002\u5de5\u5177\u9002\u7528\u4e8e\u8fd0\u7ef4\u4eba\u5458\u548c\u7cfb\u7edf\u7ba1\u7406\u5458\uff0c\u80fd\u591f\u76d1\u63a7\u7528\u6237\u64cd\u4f5c\u3001\u4fbf\u4e8e\u5ba1\u8ba1\u548c\u95ee\u9898\u6392\u67e5\u3002\u65e5\u5fd7\u6587\u4ef6\u6743\u9650\u8bbe\u7f6e\u4e3a666\uff0c\u4ee5\u652f\u6301\u591a\u7528\u6237\u5199\u5165\uff0c\u9002\u5408\u6d4b\u8bd5\u6216\u53d7\u63a7\u73af\u5883\u3002\u914d\u7f6e\u7b80\u5355\uff0c\u4ee3\u7801\u53ef\u4e00\u952e\u590d\u5236\u3002\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u4f60\u5df2\u6210\u529f\u5728 Linux \u670d\u52a1\u5668\u4e0a\u5b9e\u73b0 SSH \u547d\u4ee4\u5ba1\u8ba1\u548c\u65e5\u5fd7\u8f6e\u8f6c\u529f\u80fd\u3002\u8be5\u5de5\u5177\u8f7b\u91cf\u9ad8\u6548\uff0c\u9002\u5408\u4f01\u4e1a\u7ea7\u670d\u52a1\u5668\u7684\u8fd0\u7ef4\u5ba1\u8ba1\u573a\u666f\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/47976.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-07-30T02:12:46+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/47976.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/47976.html\",\"name\":\"Linux \u670d\u52a1\u5668\u547d\u4ee4\u5ba1\u8ba1\uff1a\u8bb0\u5f55 SSH \u547d\u4ee4\u5e76\u5b9e\u73b0\u6309\u5929\u8f6e\u8f6c - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-07-30T02:12:46+00:00\",\"dateModified\":\"2025-07-30T02:12:46+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/47976.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/47976.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/47976.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Linux \u670d\u52a1\u5668\u547d\u4ee4\u5ba1\u8ba1\uff1a\u8bb0\u5f55 SSH \u547d\u4ee4\u5e76\u5b9e\u73b0\u6309\u5929\u8f6e\u8f6c\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Linux \u670d\u52a1\u5668\u547d\u4ee4\u5ba1\u8ba1\uff1a\u8bb0\u5f55 SSH \u547d\u4ee4\u5e76\u5b9e\u73b0\u6309\u5929\u8f6e\u8f6c - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/47976.html","og_locale":"zh_CN","og_type":"article","og_title":"Linux \u670d\u52a1\u5668\u547d\u4ee4\u5ba1\u8ba1\uff1a\u8bb0\u5f55 SSH \u547d\u4ee4\u5e76\u5b9e\u73b0\u6309\u5929\u8f6e\u8f6c - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1k\u6b21\uff0c\u70b9\u8d5e29\u6b21\uff0c\u6536\u85cf7\u6b21\u3002\u672c\u6587\u4ecb\u7ecd\u5982\u4f55\u5728 Linux \u670d\u52a1\u5668\uff08\u4ee5 CentOS 7.9 \u4e3a\u4f8b\uff09\u4e0a\u5b9e\u73b0 SSH \u547d\u4ee4\u5ba1\u8ba1\uff0c\u901a\u8fc7 Bash \u811a\u672c\u8bb0\u5f55\u7528\u6237\u6267\u884c\u7684\u547d\u4ee4\u5230\u6307\u5b9a\u65e5\u5fd7\u6587\u4ef6\uff0c\u5e76\u4f7f\u7528logrotate\u5b9e\u73b0\u6309\u5929\u8f6e\u8f6c\u3002\u5de5\u5177\u9002\u7528\u4e8e\u8fd0\u7ef4\u4eba\u5458\u548c\u7cfb\u7edf\u7ba1\u7406\u5458\uff0c\u80fd\u591f\u76d1\u63a7\u7528\u6237\u64cd\u4f5c\u3001\u4fbf\u4e8e\u5ba1\u8ba1\u548c\u95ee\u9898\u6392\u67e5\u3002\u65e5\u5fd7\u6587\u4ef6\u6743\u9650\u8bbe\u7f6e\u4e3a666\uff0c\u4ee5\u652f\u6301\u591a\u7528\u6237\u5199\u5165\uff0c\u9002\u5408\u6d4b\u8bd5\u6216\u53d7\u63a7\u73af\u5883\u3002\u914d\u7f6e\u7b80\u5355\uff0c\u4ee3\u7801\u53ef\u4e00\u952e\u590d\u5236\u3002\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u4f60\u5df2\u6210\u529f\u5728 Linux \u670d\u52a1\u5668\u4e0a\u5b9e\u73b0 SSH \u547d\u4ee4\u5ba1\u8ba1\u548c\u65e5\u5fd7\u8f6e\u8f6c\u529f\u80fd\u3002\u8be5\u5de5\u5177\u8f7b\u91cf\u9ad8\u6548\uff0c\u9002\u5408\u4f01\u4e1a\u7ea7\u670d\u52a1\u5668\u7684\u8fd0\u7ef4\u5ba1\u8ba1\u573a\u666f\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/47976.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-07-30T02:12:46+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/47976.html","url":"https:\/\/www.wsisp.com\/helps\/47976.html","name":"Linux \u670d\u52a1\u5668\u547d\u4ee4\u5ba1\u8ba1\uff1a\u8bb0\u5f55 SSH \u547d\u4ee4\u5e76\u5b9e\u73b0\u6309\u5929\u8f6e\u8f6c - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-07-30T02:12:46+00:00","dateModified":"2025-07-30T02:12:46+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/47976.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/47976.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/47976.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Linux \u670d\u52a1\u5668\u547d\u4ee4\u5ba1\u8ba1\uff1a\u8bb0\u5f55 SSH \u547d\u4ee4\u5e76\u5b9e\u73b0\u6309\u5929\u8f6e\u8f6c"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/47976","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=47976"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/47976\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=47976"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=47976"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=47976"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=47976"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}