{"id":2548,"date":"2019-01-30T09:37:08","date_gmt":"2019-01-30T01:37:08","guid":{"rendered":"http:\/\/116.196.113.144\/?p=2548"},"modified":"2019-02-02T11:08:01","modified_gmt":"2019-02-02T03:08:01","slug":"ssh%e6%97%a0%e6%b3%95%e5%90%af%e5%8a%a8-codeexited-status255","status":"publish","type":"post","link":"https:\/\/www.liangliang.org.cn\/?p=2548","title":{"rendered":"ssh\u65e0\u6cd5\u542f\u52a8 (code=exited, status=255)"},"content":{"rendered":"<h3>\u670d\u52a1\u5668\u8fd0\u884c\u4e86\u4e00\u4e9b\u811a\u672c\u540e\uff0c\u7a81\u7136\u53d1\u73b0\u65e0\u6cd5ssh\u4e86\u3002<\/h3>\n<p><img decoding=\"async\" src=\"http:\/\/116.196.113.144\/wp-content\/uploads\/2019\/01\/013019_0953_sshcodee1.png\" alt=\"\" \/><\/p>\n<pre><span style=\"text-decoration: underline;\">root@X61T:\/home\/liang# service sshd restart\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">Job for ssh.service failed because the control process exited with error code.\nSee \"systemctl status ssh.service\" and \"journalctl -xe\" for details.<\/span><\/pre>\n<p>\u4f7f\u7528systemctl\u68c0\u67e5\u72b6\u6001<\/p>\n<p>Systemd\u662f\u4e00\u4e2a\u7cfb\u7edf\u7ba1\u7406\u5b88\u62a4\u8fdb\u7a0b\u3001\u5de5\u5177\u548c\u5e93\u7684\u96c6\u5408\uff0c\u7528\u4e8e\u53d6\u4ee3System V\u521d\u59cb\u8fdb\u7a0b\u3002Systemd\u7684\u529f\u80fd\u662f\u7528\u4e8e\u96c6\u4e2d\u7ba1\u7406\u548c\u914d\u7f6e\u7c7bUNIX\u7cfb\u7edf\u3002\u5728Linux\u751f\u6001\u7cfb\u7edf\u4e2d\uff0cSystemd\u88ab\u90e8\u7f72\u5230\u4e86\u5927\u591a\u6570\u7684\u6807\u51c6Linux\u53d1\u884c\u7248\u4e2d\uff0c\u53ea\u6709\u4e3a\u6570\u4e0d\u591a\u7684\u51e0\u4e2a\u53d1\u884c\u7248\u5c1a\u672a\u90e8\u7f72\u3002<\/p>\n<p>\u5e38\u7528\u7684systemctl\u547d\u4ee4\uff1a<\/p>\n<p>systemctl list-unit-files\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u5217\u51fa\u6240\u6709\u53ef\u7528\u7684\u5355\u5143<br \/>\nsystemctl list-units\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u5217\u51fa\u6240\u6709\u8fd0\u884c\u4e2d\u5355\u5143<br \/>\nsystemctl --failed\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u5217\u51fa\u6240\u6709\u5931\u8d25\u5355\u5143<br \/>\nsystemctl status firewalld.service\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u68c0\u67e5\u67d0\u4e2a\u5355\u5143\u6216\u670d\u52a1\u662f\u5426\u8fd0\u884c<br \/>\nsystemctl list-unit-files --type=service\u00a0 \u00a0 \u5217\u51fa\u6240\u6709\u670d\u52a1\uff08\u542f\u7528\u548c\u7981\u7528\uff09<br \/>\nsystemctl start httpd.service\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u542f\u52a8<br \/>\nsystemctl restart httpd.service\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u91cd\u542f<br \/>\nsystemctl stop httpd.service\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u505c\u6b62<br \/>\nsystemctl reload httpd.service\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u91cd\u8f7d\u670d\u52a1<br \/>\nsystemctl status httpd.service\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u68c0\u67e5\u72b6\u6001<\/p>\n<p>\u68c0\u67e5\u4e00\u4e0bssh.service\u7684\u72b6\u6001<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/116.196.113.144\/wp-content\/uploads\/2019\/01\/013019_0953_sshcodee2.png\" alt=\"\" \/><\/p>\n<p><span style=\"text-decoration: underline;\">root@X61T:\/home\/liang# systemctl status ssh.service <\/span><\/p>\n<p>\u53d1\u73b0<\/p>\n<pre><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">Process: 3448 ExecStart=\/usr\/sbin\/sshd -D $SSHD_OPTS (code=exited, status=255)\nProcess: 3445 ExecStartPre=\/usr\/sbin\/sshd -t (code=exited, status=0\/SUCCESS)\n......\nJan 30 08:18:03 X61T systemd[1]: Starting OpenBSD Secure Shell server...\nJan 30 08:18:03 X61T systemd[1]: ssh.service: Main process exited, code=exited, status=255\/n\/a\nJan 30 08:18:03 X61T systemd[1]: Failed to start OpenBSD Secure Shell server.\nJan 30 08:18:03 X61T systemd[1]: ssh.service: Unit entered failed state.\nJan 30 08:18:03 X61T systemd[1]: ssh.service: Failed with result 'exit-code'.<\/span><\/pre>\n<h6>\u4f7f\u7528journalctl\u8bbf\u95ee\u5185\u90e8\u7684\u6570\u636e<\/h6>\n<pre><span style=\"text-decoration: underline;\">root@X61T:\/home\/liang# journalctl -u ssh.service<\/span><\/pre>\n<p><img decoding=\"async\" src=\"http:\/\/116.196.113.144\/wp-content\/uploads\/2019\/01\/013019_0953_sshcodee3.png\" alt=\"\" \/><\/p>\n<p><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">Jan 30 08:18:03 X61T systemd[1]: Starting OpenBSD Secure Shell server...<br \/>\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">Jan 30 08:18:03 X61T systemd[1]: ssh.service: Main process exited, code=exited,<br \/>\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">Jan 30 08:18:03 X61T systemd[1]: Failed to start OpenBSD Secure Shell server.<br \/>\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">Jan 30 08:18:03 X61T systemd[1]: ssh.service: Unit entered failed state.<br \/>\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">Jan 30 08:18:03 X61T systemd[1]: ssh.service: Failed with result 'exit-code'.<br \/>\n<\/span><\/p>\n<p>systemd\u5c1d\u8bd5\u63d0\u4f9b\u4e00\u5957\u96c6\u4e2d\u5316\u7ba1\u7406\u65b9\u6848\uff0c\u4ece\u800c\u7edf\u4e00\u6253\u7406\u5168\u90e8\u5185\u6838\u53ca\u7528\u6237\u7ea7\u8fdb\u7a0b\u7684\u65e5\u5fd7\u4fe1\u606f\u3002\u8fd9\u5957\u7cfb\u7edf\u80fd\u591f\u6536\u96c6\u5e76\u7ba1\u7406\u65e5\u5fd7\u5185\u5bb9\uff0c\u800c\u8fd9\u4e5f\u5c31\u662fjournal\u3002journal\u7684\u5b9e\u73b0\u5f52\u529f\u4e8ejournald\u5b88\u62a4\u8fdb\u7a0b\uff0c\u5176\u8d1f\u8d23\u5904\u7406\u7531\u5185\u6838\u3001initrd\u4ee5\u53ca\u670d\u52a1\u7b49\u4ea7\u751f\u7684\u4fe1\u606f\u3002<\/p>\n<h6><span style=\"color: #333333;\">\u5bf9\u6bd4\u4e00\u4e0b init.d \u548c systemd \uff1a<br \/>\n<\/span><\/h6>\n<p><strong><em><span style=\"color: #333333;\">service daemon-----------------------&gt; rsyslog -----------------------------------&gt; \/var\/log<br \/>\n<\/span><\/em><\/strong><\/p>\n<p><span style=\"color: #333333;\"><strong><em>systemd ----------&gt; systemd-journald ---&gt; ram DB ----&gt; rsyslog ----&gt; \/var\/log<\/em><\/strong><br \/>\n<\/span><\/p>\n<p><span style=\"color: #333333;\">\u00a0 \u00a0 \u00a0\u5f53 systemd \u542f\u52a8\u540e\uff0csystemd-journald \u4e5f\u4f1a\u7acb\u5373\u542f\u52a8\u3002\u5c06\u65e5\u5fd7\u5b58\u5165RAM\u4e2d\uff0c\u5f53rsyslog \u542f\u52a8\u540e\u4f1a\u8bfb\u53d6\u8be5RAM\u5e76\u5b8c\u6210\u7b5b\u9009\u5206\u7c7b\u5199\u5165\u76ee\u5f55 \/var\/log \u3002\u5185\u6838\u542f\u52a8\u8fc7\u7a0b\u5c06\u6d88\u606f\u5199\u5165\u5230\u7ed3\u6784\u5316\u7684\u4e8b\u4ef6\u65e5\u5fd7\u4e2d\uff08\u6570\u636e\u5e93\uff09\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u91cd\u542f\u540e\u5220\u9664<\/span>syslog \u7684\u4fe1\u606f\u4e5f\u53ef\u4ee5\u7531 systemd-journald \u8f6c\u53d1\u5230 rsyslog \u4e2d\u8fdb\u4e00\u6b65\u5904\u7406\u9ed8\u8ba4\u60c5\u51b5\u4e0b,systemd \u7684\u65e5\u5fd7\u4fdd\u5b58\u5728 \/run\/log\/journal \u4e2d\uff0c\u7cfb\u7edf\u91cd\u542f\u5c31\u4f1a\u6e05\u9664\uff0c\u8fd9\u662fRHEL7\u7684\u65b0\u7279\u6027\u3002\u901a\u8fc7\u65b0\u5efa \/var\/log\/journal \u76ee\u5f55\uff0c\u65e5\u5fd7\u4f1a\u81ea\u52a8\u8bb0\u5f55\u5230\u8fd9\u4e2a\u76ee\u5f55\u4e2d\uff0c\u5e76\u6c38\u4e45\u5b58\u50a8\u3002rsyslog \u670d\u52a1\u968f\u540e\u6839\u636e\u4f18\u5148\u7ea7\u6392\u5217\u65e5\u5fd7\u4fe1\u606f\uff0c\u5c06\u5b83\u4eec\u5199\u5165\u5230 \/var\/log\u76ee\u5f55\u4e2d\u6c38\u4e45\u4fdd\u5b58\u5e38\u89c4\u64cd\u4f5csystemd\u63d0\u4f9b\u4e86\u81ea\u5df1\u7684\u65e5\u5fd7\u7cfb\u7edf\uff08logging system\uff09\uff0c\u79f0\u4e3a journal\u3002\u4f7f\u7528 systemd \u65e5\u5fd7\uff0c\u65e0\u9700\u989d\u5916\u5b89\u88c5\u65e5\u5fd7\u670d\u52a1\uff08syslog\uff09\u3002<\/p>\n<h6>\u8bfb\u53d6\u65e5\u5fd7\u7684\u547d\u4ee4\uff1a<\/h6>\n<p># journalctl<\/p>\n<p>\u91cd\u8981\uff1a\u663e\u793a\u6240\u6709\u7684\u65e5\u5fd7\u4fe1\u606f\uff0cnotice\u6216warning\u4ee5\u7c97\u4f53\u663e\u793a\uff0c\u7ea2\u8272\u663e\u793aerror\u7ea7\u522b\u4ee5\u4e0a\u7684\u4fe1\u606f<\/p>\n<h6>\u663e\u793a\u6700\u540e\u884c\u6570\u7684\u65e5\u5fd7\uff1a<\/h6>\n<p># journalctl -n<\/p>\n<h6>\u663e\u793a\u6700\u8be6\u7ec6\u4fe1\u606f\uff1a<\/h6>\n<p># journalctl -f<\/p>\n<p>\u63d0\u793a\uff1a\u5176\u5b9e\u5b83\u5f88\u50cftailf\u547d\u4ee4\uff0c\u9ed8\u8ba4\u663e\u793a\u5341\u884c\u3002\u968f\u7740\u5339\u914d\u65e5\u5fd7\u7684\u589e\u957f\u800c\u6301\u7eed\u8f93\u51fa\u3002\u53ea\u663e\u793a\u9519\u8bef\u3001\u51b2\u7a81\u548c\u91cd\u8981\u544a\u8b66\u4fe1\u606f<\/p>\n<p># journalctl -p err..alert<\/p>\n<pre>\u63d0\u793a\uff1a\u4e5f\u53ef\u4ee5\u4f7f\u7528\u6570\u5b57\u8868\u793a\u54df\u3002<\/pre>\n<h6>\u663e\u793a\u6307\u5b9a\u5355\u5143\u7684\u6240\u6709\u6d88\u606f\uff1a<\/h6>\n<p># journalctl -u netcfg<\/p>\n<p>\u91cd\u8981\uff1a\u4e00\u822c -u \u53c2\u6570\u662f systemctl status \u8c03\u7528\u7684\u53c2\u6570\u4e4b\u4e00\uff08journalctl -l \u53ef\u67e5\u770b\u6240\u6709\uff09\u63d0\u793a\uff1a\u5982\u679c\u5e0c\u671b\u663e\u793a kernel \u7684\u4fe1\u606f\u9700\u8981\u4f7f\u7528 journalctl -k \u8fdb\u884c\u5185\u6838\u73af\u7f13\u5b58\u6d88\u606f\u67e5\u8be2\u3002<\/p>\n<h6>\u663e\u793a\u4ece\u67d0\u4e2a\u65f6\u95f4 ( \u4f8b\u5982 20\u5206\u949f\u524d ) \u7684\u6d88\u606f:<\/h6>\n<p># journalctl --since \"20 min ago\"<\/p>\n<p># journalctl --since today<\/p>\n<p># journalctl --until YYYY-MM-DD<\/p>\n<h6>\u663e\u793a\u672c\u6b21\u542f\u52a8\u540e\u7684\u6240\u6709\u65e5\u5fd7\uff1a<\/h6>\n<p># journalctl -b<\/p>\n<p>\u4e0d\u8fc7\uff0c\u4e00\u822c\u5927\u5bb6\u66f4\u5173\u5fc3\u7684\u4e0d\u662f\u672c\u6b21\u542f\u52a8\u540e\u7684\u65e5\u5fd7\uff0c\u800c\u662f\u4e0a\u6b21\u542f\u52a8\u65f6\u7684\uff08\u4f8b\u5982\uff0c\u521a\u521a\u7cfb\u7edf\u5d29\u6e83\u4e86\uff09\u3002\u53ef\u4ee5\u4f7f\u7528 -b \u53c2\u6570\uff1a<\/p>\n<p>journalctl -b -0 \u663e\u793a\u672c\u6b21\u542f\u52a8\u7684\u4fe1\u606f<\/p>\n<p>journalctl -b -1 \u663e\u793a\u4e0a\u6b21\u542f\u52a8\u7684\u4fe1\u606f<\/p>\n<p>journalctl -b -2 \u663e\u793a\u4e0a\u4e0a\u6b21\u542f\u52a8\u7684\u4fe1\u606f<\/p>\n<p>journalctl -b -2 \u53ea\u663e\u793a\u9519\u8bef\u3001\u51b2\u7a81\u548c\u91cd\u8981\u544a\u8b66\u4fe1\u606f<\/p>\n<h6>\u663e\u793a\u7279\u5b9a\u8fdb\u7a0b\u7684\u6240\u6709\u6d88\u606f:<\/h6>\n<p># journalctl _PID=1<\/p>\n<p>1. \\_COMM \u663e\u793a\u7279\u5b9a\u7a0b\u5e8f\u7684\u6240\u6709\u6d88\u606f\uff0c\u4f8b\u5982\uff1a``journalctl \/usr\/lib\/systemd\/systemd``<br \/>\n2. \\_EXE \u8fdb\u7a0b\u7684\u53ef\u6267\u884c\u6587\u4ef6\u7684\u8def\u5f84<br \/>\n3. \\_PID \u8fdb\u7a0b\u7684PID<br \/>\n4. \\_UID \u8fd0\u884c\u8be5\u8fdb\u7a0b\u7528\u6237\u7684UID<br \/>\n5. _SYSTEMD_UNIT \u542f\u52a8\u8be5\u8fdb\u7a0b\u7684 `systemd` \u5355\u5143<br \/>\n\u63d0\u793a\uff1a\u4ee5\u4e0a\u7b5b\u9009\u6761\u4ef6\u53ef\u7ec4\u5408\u4f7f\u7528\uff0c\u4f8b\u5982\uff1ajournalctl _SYSTEMD_UNIT=sshd.service _PID=1182<\/p>\n<h6>\u663e\u793a\u66f4\u591a\u8f93\u51fa\u65b9\u6848\uff1a<\/h6>\n<p># journalctl -o short|short-iso|short-percise|short-monotonic|verbose|export|json|json-pretty|json-sse|cat<\/p>\n<h6>\u8fdb\u5165ssh debug\u6a21\u5f0f<\/h6>\n<p><img decoding=\"async\" src=\"http:\/\/116.196.113.144\/wp-content\/uploads\/2019\/01\/013019_0953_sshcodee4.png\" alt=\"\" \/><\/p>\n<p><span style=\"text-decoration: underline;\">root@X61T:\/etc\/init.d# \/usr\/sbin\/sshd -d<\/span><\/p>\n<p><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">debug1: sshd version OpenSSH_7.4, OpenSSL 1.0.2l \u00a025 May 2017<\/span><br \/>\n<span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">debug1: private host key #0: ssh-rsa SHA256:yXduj8mTB9Lte+8TNQZPaqHtphuCgTcR18BY9jhY7sY<\/span><br \/>\n<span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">debug1: private host key #1: ecdsa-sha2-nistp256 SHA256:kzdqml9P9ocCIKrNalil5lKOZtY9Eshrn6ntfFKEkFk<br \/>\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">debug1: private host key #2: ssh-ed25519 SHA256:nAcGxV9POMZeJxyqOWVsWu1s\/WrvQSyhNDj0sQa90KY<br \/>\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">debug1: rexec_argv[0]='\/usr\/sbin\/sshd'<br \/>\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">debug1: rexec_argv[1]='-d'<br \/>\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">debug1: Set \/proc\/self\/oom_score_adj from 0 to -1000<br \/>\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">debug1: Bind to port 22 on 0.0.0.0.<br \/>\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">Bind to port 22 on 0.0.0.0 failed: Address already in use.<br \/>\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">debug1: Bind to port 22 on ::.<br \/>\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\"><span style=\"color: red;\">Bind to port 22 on :: failed: Address already in use.<\/span><br \/>\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">Cannot bind any address.<\/span><\/p>\n<h6>\u53d1\u73b0\u5c45\u713622\u7aef\u53e3\u88ab\u5360\u7528\u4e86<\/h6>\n<h5>\u7528<span style=\"font-family: \u5b8b\u4f53;\">netstat\u67e5\u51fa\u662f\u8c01\u5728\u5360\u7528\u3002<br \/>\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\"><span style=\"color: #ff0000;\"><strong><span style=\"text-decoration: underline;\">root@X61T:\/etc\/init.d# netstat -apn<\/span><\/strong><\/span><br \/>\n<\/span><\/h5>\n<p><img decoding=\"async\" src=\"http:\/\/116.196.113.144\/wp-content\/uploads\/2019\/01\/013019_0953_sshcodee5.png\" alt=\"\" \/><\/p>\n<pre><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">\u5217\u51fa\u6240\u6709\u7aef\u53e3 (\u5305\u62ec\u76d1\u542c\u548c\u672a\u76d1\u542c\u7684)\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">netstat -a \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0 \u5217\u51fa\u6240\u6709\u7aef\u53e3\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">netstat -at \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0 \u5217\u51fa\u6240\u6709tcp\u7aef\u53e3\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">netstat -au \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u5217\u51fa\u6240\u6709udp\u7aef\u53e3<\/span>\n<span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">\u5217\u51fa\u6240\u6709\u5904\u4e8e\u76d1\u542c\u72b6\u6001\u7684 Sockets\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">netstat -l \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u53ea\u663e\u793a\u76d1\u542c\u7aef\u53e3\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">netstat -lt \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u53ea\u5217\u51fa\u6240\u6709\u76d1\u542c tcp \u7aef\u53e3\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">netstat -lu \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u53ea\u5217\u51fa\u6240\u6709\u76d1\u542c udp \u7aef\u53e3\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">netstat -lx \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u53ea\u5217\u51fa\u6240\u6709\u76d1\u542c UNIX \u7aef\u53e3\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">\u663e\u793a\u6bcf\u4e2a\u534f\u8bae\u7684\u7edf\u8ba1\u4fe1\u606f\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">netstat -s \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u663e\u793a\u6240\u6709\u7aef\u53e3\u7684\u7edf\u8ba1\u4fe1\u606f\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">netstat -st \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u663e\u793aTCP\u7aef\u53e3\u7684\u7edf\u8ba1\u4fe1\u606f<\/span>\n<span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">netstat -su \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u663e\u793aUDP\u7aef\u53e3\u7684\u7edf\u8ba1\u4fe1\u606f\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">\u5728netstat\u8f93\u51fa\u4e2d\u663e\u793a PID \u548c\u8fdb\u7a0b\u540d\u79f0\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">netstat \u2013pt\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">\u547d\u4ee4\u5982\u4e0b\uff1a\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">netstat -pan | grep 5623\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">#\u5176\u4e2d5623\u4f4d\u7aef\u53e3\u53f7\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">netstat \u4e2d\u53c2\u6570\u9009\u9879<\/span>\n<span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">-a\u6216--all\uff1a\u663e\u793a\u6240\u6709\u8fde\u7ebf\u4e2d\u7684Socket\uff1b\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">-A&lt;\u7f51\u7edc\u7c7b\u578b&gt;\u6216--&lt;\u7f51\u7edc\u7c7b\u578b&gt;\uff1a\u5217\u51fa\u8be5\u7f51\u7edc\u7c7b\u578b\u8fde\u7ebf\u4e2d\u7684\u76f8\u5173\u5730\u5740\uff1b\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">-c\u6216--continuous\uff1a\u6301\u7eed\u5217\u51fa\u7f51\u7edc\u72b6\u6001\uff1b<\/span>\n<span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">-C\u6216--cache\uff1a\u663e\u793a\u8def\u7531\u5668\u914d\u7f6e\u7684\u5feb\u53d6\u4fe1\u606f\uff1b\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">-e\u6216--extend\uff1a\u663e\u793a\u7f51\u7edc\u5176\u4ed6\u76f8\u5173\u4fe1\u606f\uff1b\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">-F\u6216--fib\uff1a\u663e\u793aFIB\uff1b\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">-g\u6216--groups\uff1a\u663e\u793a\u591a\u91cd\u5e7f\u64ad\u529f\u80fd\u7fa4\u7ec4\u7ec4\u5458\u540d\u5355\uff1b\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">-h\u6216--help\uff1a\u5728\u7ebf\u5e2e\u52a9\uff1b\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">-i\u6216--interfaces\uff1a\u663e\u793a\u7f51\u7edc\u754c\u9762\u4fe1\u606f\u8868\u5355\uff1b<\/span>\n<span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">-l\u6216--listening\uff1a\u663e\u793a\u76d1\u63a7\u4e2d\u7684\u670d\u52a1\u5668\u7684Socket\uff1b\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">-M\u6216--masquerade\uff1a\u663e\u793a\u4f2a\u88c5\u7684\u7f51\u7edc\u8fde\u7ebf\uff1b\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">-n\u6216--numeric\uff1a\u76f4\u63a5\u4f7f\u7528ip\u5730\u5740\uff0c\u800c\u4e0d\u901a\u8fc7\u57df\u540d\u670d\u52a1\u5668\uff1b\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">-N\u6216--netlink\u6216--symbolic\uff1a\u663e\u793a\u7f51\u7edc\u786c\u4ef6\u5916\u56f4\u8bbe\u5907\u7684\u7b26\u53f7\u8fde\u63a5\u540d\u79f0\uff1b<\/span>\n<span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">-o\u6216--timers\uff1a\u663e\u793a\u8ba1\u65f6\u5668\uff1b\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">-p\u6216--programs\uff1a\u663e\u793a\u6b63\u5728\u4f7f\u7528Socket\u7684\u7a0b\u5e8f\u8bc6\u522b\u7801\u548c\u7a0b\u5e8f\u540d\u79f0\uff1b\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">-r\u6216--route\uff1a\u663e\u793aRouting Table\uff1b\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">-s\u6216--statistice\uff1a\u663e\u793a\u7f51\u7edc\u5de5\u4f5c\u4fe1\u606f\u7edf\u8ba1\u8868\uff1b\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">-t\u6216--tcp\uff1a\u663e\u793aTCP\u4f20\u8f93\u534f\u8bae\u7684\u8fde\u7ebf\u72b6\u51b5\uff1b\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">-u\u6216--udp\uff1a\u663e\u793aUDP\u4f20\u8f93\u534f\u8bae\u7684\u8fde\u7ebf\u72b6\u51b5\uff1b\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">-v\u6216--verbose\uff1a\u663e\u793a\u6307\u4ee4\u6267\u884c\u8fc7\u7a0b\uff1b\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">-V\u6216--version\uff1a\u663e\u793a\u7248\u672c\u4fe1\u606f\uff1b\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">-w\u6216--raw\uff1a\u663e\u793aRAW\u4f20\u8f93\u534f\u8bae\u7684\u8fde\u7ebf\u72b6\u51b5\uff1b\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">-x\u6216--unix\uff1a\u6b64\u53c2\u6570\u7684\u6548\u679c\u548c\u6307\u5b9a\"-A unix\"\u53c2\u6570\u76f8\u540c\uff1b\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">--ip\u6216--inet\uff1a\u6b64\u53c2\u6570\u7684\u6548\u679c\u548c\u6307\u5b9a\"-A inet\"\u53c2\u6570\u76f8\u540c\u3002<\/span><\/pre>\n<p><span style=\"text-decoration: underline;\">root@X61T:\/etc\/init.d# service rsync stop<\/span><\/p>\n<p><span style=\"text-decoration: underline;\">root@X61T:\/etc\/init.d# \/usr\/sbin\/sshd -d<\/span><\/p>\n<pre><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">debug1: sshd version OpenSSH_7.4, OpenSSL 1.0.2l \u00a025 May 2017\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">debug1: private host key #0: ssh-rsa SHA256:yXduj8mTB9Lte+8TNQZPaqHtphuCgTcR18BY9jhY7sY<\/span>\n<span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">debug1: private host key #1: ecdsa-sha2-nistp256 SHA256:kzdqml9P9ocCIKrNalil5lKOZtY9Eshrn6ntfFKEkFk\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">debug1: private host key #2: ssh-ed25519 SHA256:nAcGxV9POMZeJxyqOWVsWu1s\/WrvQSyhNDj0sQa90KY\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">debug1: rexec_argv[0]='\/usr\/sbin\/sshd'\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">debug1: rexec_argv[1]='-d'<\/span>\n<span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">debug1: Set \/proc\/self\/oom_score_adj from 0 to -1000<\/span>\n<span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">debug1: Bind to port 22 on 0.0.0.0.<\/span>\n<span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">Server listening on 0.0.0.0 port 22.<\/span>\n<span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">debug1: Bind to port 22 on ::.\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">Server listening on :: port 22.\n<\/span><\/pre>\n<p><span style=\"font-family: \u5b8b\u4f53;\"><span style=\"text-decoration: underline;\">root@X61T:\/etc\/init.d# service rsync stop<\/span><br \/>\n<\/span><\/p>\n<p><span style=\"font-family: \u5b8b\u4f53;\"><span style=\"text-decoration: underline;\">root@X61T:\/etc\/init.d# service ssh start<\/span><br \/>\n<\/span><\/p>\n<p><span style=\"font-family: \u5b8b\u4f53;\"><span style=\"text-decoration: underline;\">root@X61T:\/etc\/init.d# service rsync start<\/span><br \/>\n<\/span><\/p>\n<p><span style=\"font-family: Arial; text-decoration: underline;\">root@X61T:\/home\/liang# journalctl -u ssh.service<\/span><\/p>\n<pre><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">Jan 30 09:21:38 X61T systemd[1]: Starting OpenBSD Secure Shell server...\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">Jan 30 09:21:38 X61T sshd[6526]: Server listening on 0.0.0.0 port 22.\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">Jan 30 09:21:38 X61T sshd[6526]: Server listening on :: port 22.\n<\/span><span style=\"font-family: \u5b8b\u4f53; font-size: 10pt;\">Jan 30 09:21:38 X61T systemd[1]: Started OpenBSD Secure Shell server.\n<\/span><\/pre>\n<p><img decoding=\"async\" src=\"http:\/\/116.196.113.144\/wp-content\/uploads\/2019\/01\/013019_0953_sshcodee6.png\" alt=\"\" \/><\/p>\n<p>\u641e\u5b9a\u3002<\/p>\n<p>\u4e0b\u9762\u7684\u8d44\u6599\u662f\u4e3a\u4ec0\u4e48<span style=\"color: #555555;\"><span style=\"font-family: Helvetica;\">Rsync<\/span><span style=\"font-family: \u5b8b\u4f53;\">\u4f1a\u5360\u7528<\/span><span style=\"font-family: Helvetica;\">22<\/span><span style=\"font-family: \u5b8b\u4f53;\">\u7aef\u53e3<\/span><span style=\"font-family: Helvetica;\"><br \/>\n<\/span><\/span><\/p>\n<p>\u7559\u4e0b\u6765\u53c2\u8003<\/p>\n<p>https:\/\/mike-hostetler.com\/rsync-non-standard-ssh-port\/<\/p>\n<p>https:\/\/www.kaijia.me\/2012\/10\/rsync-use-non-standard-ssh-port-solved\/<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u670d\u52a1\u5668\u8fd0\u884c\u4e86\u4e00\u4e9b\u811a\u672c\u540e\uff0c\u7a81\u7136\u53d1\u73b0\u65e0\u6cd5ssh\u4e86\u3002 root@X61T:\/home\/liang# service sshd restart Job for ssh.service failed becau&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[60],"tags":[],"class_list":["post-2548","post","type-post","status-publish","format-standard","hentry","category-ssh"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.liangliang.org.cn\/index.php?rest_route=\/wp\/v2\/posts\/2548","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.liangliang.org.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.liangliang.org.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.liangliang.org.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.liangliang.org.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2548"}],"version-history":[{"count":14,"href":"https:\/\/www.liangliang.org.cn\/index.php?rest_route=\/wp\/v2\/posts\/2548\/revisions"}],"predecessor-version":[{"id":2642,"href":"https:\/\/www.liangliang.org.cn\/index.php?rest_route=\/wp\/v2\/posts\/2548\/revisions\/2642"}],"wp:attachment":[{"href":"https:\/\/www.liangliang.org.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2548"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.liangliang.org.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2548"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.liangliang.org.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2548"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}