{"id":584,"date":"2019-12-30T12:13:02","date_gmt":"2019-12-30T04:13:02","guid":{"rendered":"http:\/\/47.242.20.44\/?p=584"},"modified":"2021-12-19T20:01:06","modified_gmt":"2021-12-19T12:01:06","slug":"%e5%8a%a0%e5%af%86%e4%bc%a0%e4%b8%8e%e8%ae%a4%e8%af%81%ef%bc%8c%e6%9c%8d%e5%8a%a1%e5%99%a8%e5%ae%89%e5%85%a8%e7%ad%96%e7%95%a5","status":"publish","type":"post","link":"https:\/\/blog.zengqq.com.cn\/?p=584","title":{"rendered":"\u52a0\u5bc6\u4e0e\u8ba4\u8bc1\uff0c\u670d\u52a1\u5668\u901a\u4fe1\u5b89\u5168(Procedure)"},"content":{"rendered":"\n<p>\u524d\u8a00<br>\u5728\u5efa\u7acbCCTV\u670d\u52a1\u7684\u65f6\u5019\u7ecf\u5e38\u8981\u5c06\u4e00\u4e9b\u6587\u4ef6\u4f20\u8f93\u5230\u53e6\u5916\u4e00\u4e2a\u670d\u52a1\u5668\u4e0a\uff0c\u800c\u4e14\u90fd\u662fLinux\u7684\u547d\u4ee4\u884c\u73af\u5883\uff0c\u90a3\u4e48\u5bf9\u4e8e\u6211\u6765\u8bb2scp\u5c31\u662f\u6700\u76f4\u63a5\u6709\u6548\u7684\u65b9\u6cd5\u4e86\uff0c\u5176\u4ed6\u8bf8\u5982FTP\u3001SMB\u4ee5\u53caWinscp\u8fd9\u4e9b\u6709\u754c\u9762\u7684\u6587\u4ef6\u4f20\u8f93\u5de5\u5177\u5230\u53cd\u800c\u6709\u4e9b\u591a\u4f59\u4e86\u3002\u4f7f\u7528\u8fc7scp\u7684\u90fd\u77e5\u9053\u9700\u8981\u6307\u5b9a\u8fdc\u7aef\u670d\u52a1\u5668\u7684\u5e10\u53f7\u5e76\u624b\u52a8\u8f93\u5165\u5bc6\u7801\uff0c\u90a3\u4e48\u5982\u4f55\u907f\u514d\u6bcf\u6b21\u90fd\u9700\u8981\u8f93\u5165\u5bc6\u7801\u8fd9\u4e2a\u64cd\u4f5c\u5462\uff1f\u4e0b\u9762\u5c31\u7ed9\u51fa\u4e24\u79cd\u65b9\u6848\u8fdb\u884c\u89e3\u51b3\u3002<\/p>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<ul class=\"wp-block-list\"><li>\u65b9\u6cd5\u4e00\uff08\u6700\u597d\u7684\u529e\u6cd5\uff09\uff1a\u5efa\u7acbSSH\u7684\u4fe1\u4efb\u5173\u7cfb<ul><li>\u5728A\u4e0a\u7684Linux\u4e0a\u4f7f\u7528ssh-keygen\u5de5\u5177\u6765\u751f\u6210\u516c\u79c1\u94a5\u5bf9<strong>id_rsa<\/strong> \u548c<strong>id_rsa.pub<\/strong><\/li><\/ul><\/li><\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">MBP:.ssh qxxxxxzeng$ ssh-keygen -t rsa\nGenerating public\/private rsa key pair.\nEnter file in which to save the key (\/Users\/qxxxxxzeng\/.ssh\/id_rsa): \nEnter passphrase (empty for no passphrase): \nEnter same passphrase again: \nYour identification has been saved in \/Users\/qxxxxxzeng\/.ssh\/id_rsa.\nYour public key has been saved in \/Users\/qxxxxxzeng\/.ssh\/id_rsa.pub.\nThe key fingerprint is:\nSHA256:qJmWKqbhGQSpyrQtntfMLK5ExiixuJczILIly1T6RWU qxxxxxzeng@MBP\nThe key's randomart image is:\n+---[RSA 3072]----+\n|       E         |\n| .    o          |\n|+  . .           |\n|*oo .  .         |\n|@O.  .. S        |\n|&amp;B+..=           |\n|*B=o@            |\n|=+=B =           |\n|+B=..            |\n+----[SHA256]-----+\nMBP:.ssh qxxxxxzeng$ <\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>\u5c06<strong>id_rsa.pub<\/strong>\u53d1\u7ed9B\uff0cB\u5c06<strong>id_rsa.pub<\/strong>\u653e\u5165B\u7528\u6237\u540d\u4e0b\u7684\u4fe1\u4efb\u79d8\u94a5Authentication_keys\u5185<ul><li><ol><li>scp ~\/.ssh\/<strong>id_rsa.pub<\/strong> B@ip:~\/.ssh<\/li><li>cat ~\/.ssh\/<strong>id_rsa.pub<\/strong> >> ~\/.ssh\/authorized_keys<\/li><li>\u8d4b\u6743\u548c\u4fee\u6539\u7528\u6237755\uff08\u7fa4\u6656\u9700\u8981\u5c06\u7528\u6237777\u53d8\u6210755\u6765\u5b9e\u73b0\u514d\u5bc6\u7801\u767b\u5f55\uff09<\/li><li>\u4fee\u6539sshd_config\uff0c\u542f\u52a8RSA Authentication<\/li><li>\u91cd\u542fB\u7684ssh\u670d\u52a1<\/li><\/ol><\/li><li>\u4ece\u6b64\uff0c\u5728A\u4e0a\u5229\u7528scp\u52a0\u5bc6\u4f20\u8f93\u7684\u5185\u5bb9\u5c31\u81ea\u52a8\u7531B\u7684Authentication Keys\u7ed9\u4e0e\u767b\u5f55\u8ba4\u8bc1\u7684\u4fe1\u606f\uff0c\u800c\u65e0\u9700\u518d\u6b21\u8f93\u5165\u5bc6\u7801\u3002<\/li><\/ul><\/li><\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#\u8d4b\u6743\uff1a\uff08\u6ce8\u610f~\/.ssh\u4e00\u5b9a\u8981\u662f700,\u4e5f\u5c31\u662f\u53ea\u7528\u4f5c\u8005\u201c\u53ef\u8bfb\u53ef\u5199\u53ef\u6267\u884c\u201d\uff0c\u5426\u5219\u8fd8\u4f1a\u88ab\u5224\u5b9a\u4e0d\u5b89\u5168\nchmod 755 ~\nchmod 600 ~\/.ssh\/authorized_keys\nchmod 700 ~\/.ssh\n#\u4fee\u6539 sshd_config\uff0c\u542f\u52a8RSA Authentication\uff0c\u5c06#\u53bb\u6389\u5c31\u662fenable\uff0c\u5177\u4f53\u5982\u4e0b\nsudo vim \/etc\/ssh\/sshd_config\n#RSAAuthentication yes\n#PubkeyAuthentication yes\n#AuthorizedKeysFile .ssh\/authorized_keys<\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>\u9884\u5907\uff0c\u4e24\u4e2a\u77e5\u8bc6\u70b9<ul><li>\u516c\u94a5\u548c\u79c1\u94a5<ul><li>\u516c\u94a5<ul><li><strong>SSH\u516c\u94a5(~\/.ssh\/id_rsa.pub)<\/strong>, \u5728~\/.ssh\/id_rsa.pub\u6587\u4ef6\u4e2d\u5305\u542b\u4e86\u8ba4\u8bc1\u7684\u516c\u94a5\u4fe1\u606f\uff0c\u800c\u4e14\u8be5\u6587\u4ef6\u53ef\u4ee5\u88ab\u4efb\u4f55\u4eba\u8bfb\u53d6\uff1b<\/li><li><strong>\u516c\u94a5\u6388\u6743\u6587\u4ef6(~\/.ssh\/authorized_keys)<\/strong>\uff0c\u5728~\/.ssh\/authorized_keys\u6587\u4ef6\u4e2d\u5219\u5217\u4e3e\u4e86\u767b\u5f55\u7528\u6237\u7684\u516c\u94a5\u4fe1\u606f(\u6362\u53e5\u8bdd\u8bf4\u5c31\u662f\u4f7f\u7528\u8fd9\u4e9b\u516c\u94a5\u4fe1\u606f\u53ef\u4ee5\u767b\u5f55\u5f53\u524d\u8bbe\u5907)\uff0c\u800c\u4e3a\u4e86\u5b89\u5168\u8003\u8651\uff0c\u8be5\u6587\u4ef6\u4e00\u822c\u5efa\u8bae\u53ea\u6709\u672c\u7528\u6237\u53ef\u4ee5\u6709\u8bfb\u5199\u6743\u9650\u3002<\/li><li>\u8fd9\u4e24\u4e2a\u6587\u4ef6\u7684\u4f5c\u7528\u5177\u4f53\u53ef\u4ee5\u53c2\u8003ssh\u7684man\u624b\u518c\uff1a<\/li><\/ul><\/li><li>\u79c1\u94a5\uff0c<ul><li>\u63d0\u5230\u516c\u94a5\u5bf9\u5e94\u7684\u5c31\u4f1a\u6709\u79c1\u94a5\uff0c\u5728\u8c08\u8fd9\u4e24\u4e2a\u6982\u5ff5\u4e4b\u524d\u6211\u4eec\u5148\u4e86\u89e3\u53e6\u5916\u4e00\u7ec4\u6982\u5ff5\uff1a<\/li><\/ul><\/li><\/ul><\/li><\/ul><ul><li>\u52a0\u5bc6\u548c\u8ba4\u8bc1\uff1a<ul><li><strong>\u52a0\u5bc6<\/strong>\uff0c\u662f\u5bf9\u6570\u636e\u8fdb\u884c\u5904\u7406\uff0c\u6dfb\u52a0<strong><span style=\"text-decoration: underline;\">\u4fdd\u62a4<\/span><\/strong>\u4fe1\u606f\uff0c\u5982\u679c\u975e\u6cd5\u7528\u6237\u5f97\u5230\u88ab\u52a0<span style=\"text-decoration: underline;\">\u5bc6\u8fc7\u7684\u6570\u636e<\/span>\uff0c\u4e5f<span style=\"text-decoration: underline;\">\u65e0\u6cd5\u83b7\u53d6<\/span>\u5230\u539f\u59cb\u7684\u6709\u6548\u6570\u636e\u5185\u5bb9\uff0c\u6240\u4ee5\u52a0\u5bc6\u7684\u91cd\u70b9\u5728\u4e8e\u6570\u636e\u7684\u5b89\u5168\u6027\u3002<\/li><li><span class=\"has-inline-color has-highlight-color\"><strong>\u8ba4\u8bc1<\/strong>\uff0c\u662f\u5bf9\u6570\u636e\u8fdb\u884c\u5904\u7406\uff0c\u6dfb\u52a0<strong><span style=\"text-decoration: underline;\">\u9274\u6743<\/span><\/strong>\u4fe1\u606f\uff0c\u5982\u679c\u5728\u4f20\u8f93\u7684\u8fc7\u7a0b\u4e2d\u88ab<span style=\"text-decoration: underline;\">\u975e\u6cd5\u7be1\u6539<\/span>\uff0c\u63a5\u6536\u65b9\u5c31\u4f1a<span style=\"text-decoration: underline;\">\u6821\u9a8c\u5931\u8d25\u5e76\u4e22\u5f03<\/span>\u8be5\u975e\u6cd5\u6570\u636e\uff0c\u6240\u4ee5\u8ba4\u8bc1\u7684\u91cd\u70b9\u5728\u4e8e\u6570\u636e\u7684\u5408\u6cd5\u6027\u3002<\/span>\u767b\u5f55\u5c31\u662f\u4e00\u79cd\u8ba4\u8bc1\uff0c\u6211\u7b49\u4e0b\u8981\u7528\u79d8\u94a5\u767b\u5f55\u5c31\u662f\u8ba4\u8bc1\u7684\u5e94\u7528\u3002<\/li><li>\u4e0a\u9762\u662f\u4ece\u4e1a\u52a1\u6982\u5ff5\u6765\u4e0a\u63cf\u8ff0\u4e86\u52a0\u5bc6\u548c\u8ba4\u8bc1\u7684\u533a\u522b\uff0c\u4f46\u662f\u4ece\u5177\u4f53\u6280\u672f\u5b9e\u73b0\u4e0a\uff0c\u8ba4\u8bc1\u4f7f\u7528\u7684\u662f\u52a0\u5bc6\u4e2d\u7684<strong>\u975e\u5bf9\u79f0\u52a0\u5bc6\u7b97\u6cd5<\/strong>\u6765\u5b9e\u73b0\u9274\u6743\u548c\u8ba4\u8bc1\u7684\u64cd\u4f5c\u3002\u975e\u5bf9\u79f0\u52a0\u5bc6\u7b97\u6cd5\u9700\u8981\u4e24\u4e2a\u5bc6\u94a5\u6765\u8fdb\u884c\u52a0\u5bc6\u548c\u89e3\u5bc6\uff0c\u8fd9\u4e24\u4e2a\u79d8\u94a5\u5206\u522b\u662f<ul><li>\u516c\u5f00\u5bc6\u94a5(public key\uff0c\u7b80\u79f0\u516c\u94a5)<\/li><li>\u79c1\u6709\u5bc6\u94a5(private key\uff0c\u7b80\u79f0\u79c1\u94a5)<\/li><\/ul><\/li><\/ul><\/li><\/ul><\/li><\/ul>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<ul class=\"wp-block-list\"><li><\/li><\/ul>\n<\/div><\/div>\n<\/div><\/div>\n<\/div><\/div>\n<\/div><\/div>\n<\/div><\/div>\n<\/div><\/div>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>&nbsp;~\/.ssh\/id_rsa.pub<br> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; Contains the public key for authentication.&nbsp; These files are not sensitive and can (but need not) be readable by anyone.<\/p><p>~\/.ssh\/authorized_keys<br> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; Lists the public keys (DSA\/ECDSA\/RSA) that can be used for logging in as this user.&nbsp; The format of this file is described in the sshd(8) manual page.&nbsp; This file is not highly sensitive, but the recommended permissions are read\/write for the user, and not accessible by others.<\/p><\/blockquote>\n<\/div><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>\u5bf9\u79f0\u52a0\u5bc6\u7b97\u6cd5\u5728\u52a0\u5bc6\u548c\u89e3\u5bc6\u65f6\u4f7f\u7528\u7684\u662f\u540c\u4e00\u4e2a\u79d8\u94a5\uff1b<br> <br> \u4e0b\u9762\u5c31\u5206\u522b\u63cf\u8ff0\u4e00\u4e0b\uff0c\u91c7\u7528\u975e\u5bf9\u79f0\u7b97\u6cd5(\u5373\u4f7f\u7528\u516c\u94a5\u548c\u79c1\u94a5)\u7684\u52a0\u5bc6\u548c\u8ba4\u8bc1\u5404\u81ea\u7684\u8fc7\u7a0b\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>ssh-keygen : authentication key generation, management and conversion<br> &nbsp;-t&nbsp;&nbsp; &nbsp;type<br> &nbsp;&nbsp; &nbsp; Specifies the type&nbsp;&nbsp; &nbsp;of key to create.&nbsp; The possible&nbsp;&nbsp; &nbsp;values are &#8216;rsa1&#8217; for protocol version 1 and &#8216;dsa&#8217;, &#8216;ecdsa&#8217;, &#8216;ed25519&#8217;, or &#8216;rsa&#8217; for protocol version 2.<\/p><\/blockquote>\n\n\n\n<ul class=\"wp-block-list\"><li>\u57fa\u4e8e\u516c\u94a5\u548c\u79c1\u94a5\u7684<strong><span class=\"has-inline-color has-highlight-color\">\u52a0\u5bc6\u8fc7\u7a0b<\/span><\/strong><ul><li>\u6709\u4e24\u4e2a\u7528\u6237Alice\u548cBob\uff0cAlice\u60f3\u628a\u4e00\u6bb5\u6570\u636e\u52a0\u5bc6\u540e\u53d1\u9001\u7ed9Bob\u4ee5\u53caBob\u516c\u53f8\u6240\u6709\u4eba(\u6ce8\u610f\u8fd9\u91cc\u5f3a\u8c03\u7684\u662f\u6570\u636e\u7684\u5b89\u5168\u6027)\uff0c\u90a3\u4e48\u5982\u4f55\u4fdd\u8bc1\u9664\u4e86Bob\u4e4b\u5916\u7684\u4eba\u5373\u4f7f\u7a83\u53d6\u4e86\u6570\u636e\u4e5f\u65e0\u6cd5\u89e3\u5bc6\u5f97\u5230\u539f\u59cb\u7684\u6570\u636e\uff1f\u57fa\u4e8e\u516c\u94a5\u548c\u79c1\u94a5\u7684\u52a0\u5bc6\u53ef\u4ee5\u5b8c\u6210\u8fd9\u4e2a\u9700\u6c42\uff0c\u5177\u4f53\u6d41\u7a0b\u5982\u4e0b\uff1a<ul><li>Bob\u5c06\u4ed6\u7684\u516c\u94a5\u53d1\u9001\u7ed9Alice<\/li><li>Alice\u7528Bob\u7684\u516c\u94a5\u52a0\u5bc6\u9700\u8981\u4f20\u8f93\u7684\u6570\u636e\u7136\u540e\u53d1\u9001\u7ed9Bob\u548c\u5176\u4ed6\u6240\u6709\u4eba<br>\u53ea\u6709Bob\u7528\u4ed6\u7684\u79c1\u94a5\u89e3\u5bc6Alice\u7684\u6d88\u606f\uff0c\u5176\u4ed6\u4eba\u6ca1\u6709\u79c1\u94a5\uff0c\u89e3\u5bc6\u4e0d\u4e86\u3002<\/li><\/ul><\/li><\/ul><\/li><li>\u57fa\u4e8e\u516c\u94a5\u548c\u79c1\u94a5\u7684<strong><span class=\"has-inline-color has-highlight-color\">\u8ba4\u8bc1\u8fc7\u7a0b<\/span><\/strong><ul><li>\u8fd8\u662fAlice\u548cBob\uff0cAlice\u60f3\u628a\u4e00\u6bb5\u6570\u636e\u53d1\u9001\u7ed9Bob(\u6ce8\u610f\u8fd9\u91cc\u5e76\u4e0d\u5f3a\u8c03\u6570\u636e\u7684\u5b89\u5168\u6027)\uff0c\u5f53Bob\u6536\u5230\u6570\u636e\u65f6\u5982\u4f55\u5224\u65ad\u8be5\u6570\u636e\u786e\u5b9e\u662fAlic\u53d1\u9001\u7684\u4e14\u4f20\u8f93\u8fc7\u7a0b\u4e2d\u6ca1\u6709\u88ab\u7be1\u6539\uff1f\u57fa\u4e8e\u516c\u94a5\u548c\u79c1\u94a5\u7684\u8ba4\u8bc1\u53ef\u4ee5\u5b8c\u6210\u8fd9\u4e2a\u9700\u6c42\uff0c\u5177\u4f53\u6d41\u7a0b\u5982\u4e0b\uff1a<ul><li>Alice\u7528\u5979\u7684\u79c1\u94a5\u5bf9\u6570\u636e\u52a0\u5bc6(\u6216\u8005\u5bf9\u4e8e\u6570\u636e\u7684\u54c8\u5e0c\u503c\u8fdb\u884c\u52a0\u5bc6\u4f5c\u4e3a\u7b7e\u540d)<\/li><li>Alice\u5c06\u52a0\u5bc6\u540e\u7684\u6570\u636e(\u6216\u8005\u660e\u6587\u6570\u636e+\u7b7e\u540d)\u53d1\u9001\u7ed9Bob<\/li><li>Bob \u6267\u884c cat id_rsa.pub &gt;&gt; authorized_keys<\/li><li>Bob\u7528Alice\u7684\u516c\u94a5\u89e3\u5bc6\u6570\u636e(\u6216\u6821\u9a8c\u7b7e\u540d)\uff0c\u5982\u679c\u89e3\u5bc6(\u6821\u9a8c)\u6210\u529f\u5219\u53ef\u4ee5\u4fdd\u8bc1\u6570\u636e\u7684\u53d1\u9001\u65b9\u80af\u5b9a\u662fAlice<\/li><\/ul><\/li><\/ul><\/li><li>\u57fa\u4e8e\u516c\u94a5\u548c\u79c1\u94a5\u7684\u4fe1\u4efb\u5173\u7cfb<ul><li><span class=\"has-inline-color has-highlight-color\">\u4e86\u89e3\u4e86\u516c\u94a5\/\u79c1\u94a5\u4ee5\u53ca\u52a0\u5bc6\/\u8ba4\u8bc1\u8fd9\u4e9b\u6982\u5ff5\u540e\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u5728scp\u4e2d\u4f7f\u7528\u516c\u94a5\/\u79c1\u94a5\u6765\u5efa\u7acb\u4e00\u4e2a\u4fe1\u4efb\u5173\u7cfb\uff0c\u4ece\u800c\u5728\u6570\u636e\u4f20\u8f93\u65f6\u5b8c\u6210\u81ea\u52a8\u8ba4\u8bc1\u800c\u65e0\u9700\u8f93\u5165\u5bc6\u7801<\/span>\u3002<\/li><li>\u5982\u4f55\u8ba4\u8bc1\uff1a<ul><li>\u5982\u4f55\u52a0\u5bc6\uff1aUser\u5728A\u4e3b\u673a\u4e0a\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u516c\u79c1\u94a5\u5bf9\uff0c\u516c\u94a5scp\u7ed9B\uff0c\u79c1\u94a5\u7ed9A\u3002\u5728B\u4e3b\u673a\u4e0a\uff0c\u5c06User\u5728A\u4e3b\u673a\u7684\u516c\u94a5\u52a0\u5165\u5230ssh\u7684\u4fe1\u4efb\u516c\u94a5\u5217\u8868authorized_keys\u4e2d(\u5373\u516c\u94a5\u6388\u6743\u6587\u4ef6~\/.ssh\/authorized_keys)<\/li><li>User\u5728A\u4e3b\u673a\u5c06SCP\u8bf7\u6c42\u4f7f\u7528\u81ea\u5df1\u7684\u79c1\u94a5\u8fdb\u884c\u52a0\u5bc6\uff0c\u7136\u540e\u4f20\u8f93\u7ed9B\u4e3b\u673a<\/li><li>B\u4e3b\u673a\u5728\u6536\u5230SCP\u8bf7\u6c42\u65f6\uff0c\u4f7f\u7528User\u7684\u516c\u94a5\u8fdb\u884c\u89e3\u5bc6<\/li><li>\u5982\u679c\u89e3\u5bc6\u6210\u529f\uff0c\u5219\u8868\u793a\u8be5\u8bf7\u6c42\u786e\u5b9e\u662fUser\u53d1\u9001\u7684\u8bf7\u6c42\uff0c\u5219\u5141\u8bb8\u64cd\u4f5c\uff1b\u5982\u679c\u89e3\u5bc6\u5931\u8d25\uff0c\u5219\u8868\u793a\u8be5\u8bf7\u6c42\u65e0\u6548\uff0c\u76f4\u63a5\u4e22\u5f03<\/li><\/ul><\/li><li>\u6240\u4ee5\u8fd9\u91cc\u7684\u9700\u8981\u505a\u7684\u5c31\u662f\uff1a<ul><li>\u521b\u5efa\u516c\u79c1\u94a5\u5bf9<ul><li> \u5728A\u4e0a\u7684Linux\u4e0a\u4f7f\u7528ssh-keygen\u5de5\u5177\u6765\u751f\u6210\u516c\u79c1\u94a5\u5bf9\uff0c\u5728man\u624b\u518c\u4e2d\u5173\u4e8essh-keygen\u5de5\u5177\u7684\u8bf4\u660e\u5982\u4e0b\uff1a<\/li><\/ul><\/li><\/ul><\/li><\/ul><\/li><\/ul>\n\n\n\n<p class=\"has-drop-cap\"><br> \u6211\u81ea\u5df1\u7684\u6837\u5f0f\uff1a\uff08\u6ce8\u610f\uff0ccctv\u5c31\u662f\u4e0a\u6587\u7684A\uff0c\u800c\u5b58\u50a8\u670d\u52a1\u5668\u5c31\u662fB\uff09<br><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong><em>pi@raspberrypi:~ $ ssh-keygen -t rsa\nGenerating public\/private rsa key pair.\nEnter file in which to save the key (\/home\/pi\/.ssh\/id_rsa): \nCreated directory '\/home\/pi\/.ssh'.\nEnter passphrase (empty for no passphrase): \nEnter same passphrase again: \nYour identification has been saved in \/home\/pi\/.ssh\/id_rsa.\nYour public key has been saved in \/home\/pi\/.ssh\/id_rsa.pub.\nThe key fingerprint is:\nSHA256:rmcdf8g3xs1131WujDZIsDTkwLnltMoWrO3Gxg3nP1Q pi@raspberrypi\nThe key's randomart image is:\n+---[RSA 2048]----+\n|     ..o=       .|\n|o     o+ +. .  ..|\n|..  .  .o+..... o|\n|     + o.++o.+ oo|\n|      = So+o+ o o|\n|  oo   *..E. .   |\n|        *O.      |\n|       + =B      |\n| ..o  .  +o.     |\n+----[SHA256]-----+\npi@raspberrypi:~ $ \npi@raspberrypi:~\/.ssh $ <\/em>scp \/home\/pi\/.ssh\/id_rsa.pub pi@192.168.1.106:\/home\/pi\/.ssh\/authorized_keys<em> <\/em><\/strong>\n<strong><em>The authenticity of host '192.168.1.106 (192.168.1.106)' can't be established. ECDSA key fingerprint is SHA256:lMiyrBGB1xz40\/x4syemMcbIA0kS5eMAGFp1zrz9Moo. Are you sure you want to continue connecting (yes\/no)? yes Warning: Permanently added '192.168.1.106' (ECDSA) to the list of known hosts. pi@192.168.1.106's password:  id_rsa.pub                                                        100%  396    48.1KB\/s   00:00\npi@raspberrypi:~ $ ssh pi@192.168.1.106 <\/em><\/strong>\n<strong><em>Linux raspberrypi3 4.19.75-v7+ #1270 SMP Tue Sep 24 18:45:11 BST 2019 armv7l The programs included with the Debian GNU\/Linux system are free software; <\/em><\/strong>\n<strong><em>the exact distribution terms for each program are described in the individual files in \/usr\/share\/doc\/*\/copyright. <\/em><\/strong>\n<strong><em>Debian GNU\/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. <\/em><\/strong>\n<strong><em>Last login: Sun Feb  2 12:09:14 2020 from 192.168.1.117 pi@raspberrypi3:~ $ exit <\/em><\/strong>\n<strong><em>logout Connection to 192.168.1.106 closed. <\/em><\/strong>\n<strong><em>pi@raspberrypi:~ $ <\/em><\/strong><\/pre>\n\n\n\n<p>\u5728\u4e0a\u9762\u63d0\u5230\u4e86ssh-keygen\u652f\u6301rsa1\u3001dsa\u3001ecdsa\u3001ed25519\u548crsa\u8fd9\u51e0\u79cd\u975e\u5bf9\u79f0\u52a0\u5bc6\u7b97\u6cd5\uff0c\u5176\u4e2d\u6700\u5e38\u7528\u7684\u5c31\u662fRSA\u548cDSA.<br> \u6ce8\u610f\u4e0a\u9762\u6709\u4e09\u5904\u9700\u8981\u8f93\u5165\u4fe1\u606f\uff0c\u5206\u522b\u662f\uff1a<br> \u5b58\u50a8\u516c\u79c1\u94a5\u7684\u6587\u4ef6\u5939\u4f4d\u7f6e\uff0c\u5982\u679c\u4e0d\u8f93\u5165\uff0c\u5219\u9ed8\u8ba4\u4e3a~\/.ssh\/\uff0c\u6587\u4ef6\u540d\u5219\u9ed8\u8ba4\u662fid_rsa\u548cid_rsa.pub<br> \u4f7f\u7528\u8be5\u516c\u79c1\u94a5\u65f6\u662f\u5426\u9700\u8981\u5bc6\u7801\uff0c\u5982\u679c\u4e0d\u8f93\u5165\u5219\u8868\u793a\u4e0d\u9700\u8981\u5bc6\u7801\uff08<span class=\"has-inline-color has-highlight-color\">\u6211\u7684\u5efa\u8bae\u662f\uff1a\u80fd\u4e0d\u8f93\u5165\u5c31\u4e0d\u8f93\u5165<\/span>\uff09<br> \u518d\u6b21\u786e\u8ba4\u662f\u5426\u9700\u8981\u5bc6\u7801<br> \u5c06User\u5728A\u4e3b\u673a\u7684\u516c\u94a5\u52a0\u5165\u5230ssh\u7684\u4fe1\u4efb\u516c\u94a5\u5217\u8868\u4e2d<br> \u5c06\u521a\u624d\u521b\u5efa\u7684~\/.ssh\/id_rsa.pub\u6587\u4ef6\u4e2d\u7684\u5185\u5bb9\u62f7\u8d1d\u6dfb\u52a0\u5230B\u4e3b\u673a\u4e0a\u7684~\/.ssh\/authorized_keys\u6587\u4ef6\u4e2d(\u5982\u679c\u6ca1\u6709\u5219\u521b\u5efa\u4e00\u4e2a)\uff0c\u8fd9\u4e2a\u65f6\u5019\u5c31\u5efa\u7acb\u4e86\u4e00\u6761A&#8211;&gt;B\u7684\u4fe1\u4efb\u5173\u7cfb\u3002\u6ce8\u610f\u8fd9\u4e2a\u4fe1\u4efb\u5173\u7cfb\u662f\u6709\u65b9\u5411\u6027\u7684\uff0c\u5982\u679c\u8981\u5efa\u7acb\u4eceB&#8211;&gt;A\u7684\u4fe1\u4efb\u5173\u7cfb\uff0c\u5219\u64cd\u4f5c\u6b65\u9aa4\u548c\u4e0a\u9762\u7684\u7c7b\u4f3c\uff0c\u53ea\u4e0d\u8fc7\u8981\u53cd\u8fc7\u6765\u3002<\/p>\n\n\n\n<p>\u5efa\u7acb\u597d\u4fe1\u4efb\u5173\u7cfb\u540e\uff0c\u8fd9\u4e2a\u65f6\u5019\u4f7f\u7528\u4efb\u4f55ssh\u76f8\u5173\u7684\u5de5\u5177\u5219\u90fd\u65e0\u9700\u8f93\u5165\u8fdc\u7aef\u7684\u767b\u9646\u5bc6\u7801(\u5982\u679c\u5728\u521b\u5efa\u516c\u79c1\u94a5\u5bf9\u65f6\u8f93\u5165\u4e86\u5bc6\u7801\uff0c\u90a3\u4e48\u8fd9\u4e2a\u65f6\u5019\u8fd8\u9700\u8981\u8f93\u5165\u8fd9\u4e2a\u5bc6\u7801\u624d\u80fd\u4f7f\u7528\u516c\u79c1\u94a5\u5bf9)\u3002<\/p>\n\n\n\n<p>\u65b9\u6cd5\u4e8c\uff1a\u4f7f\u7528sshpass\u5de5\u5177\u6765\u81ea\u52a8\u8f93\u5165\u5bc6\u7801<br>\u5176\u5b9e\u4e0a\u9762\u7684\u5efa\u7acb\u4fe1\u4efb\u5173\u7cfb\u7684\u505a\u6cd5\u662f\u6700\u65b9\u4fbf\u548c\u5b89\u5168\u7684\u505a\u6cd5\uff0c\u4f46\u662f\u5728\u6709\u4e9b\u573a\u666f\u4e0b(\u6bd4\u5982\u8fdc\u7aef\u7684authorized_keys\u662f\u4e0d\u80fd\u968f\u610f\u66f4\u6539\u7684)\uff0c\u90a3\u4e48\u8fd9\u4e2a\u65f6\u5019\u6211\u4eec\u5c31\u53ef\u4ee5\u501f\u52a9sshpass\u8fd9\u4e2a\u7b2c\u4e09\u65b9\u5de5\u5177\u6765\u5b8c\u6210ssh\u8fde\u63a5\u65f6\u7684\u5bc6\u7801\u8f93\u5165\u3002\u5148\u770b\u4e00\u4e0bsshpass\u7684man\u624b\u518c\u4e2d\u662f\u5982\u4f55\u63cf\u8ff0\u7684\uff1a(\u7701\u7565\uff09<\/p>\n\n\n\n<p>\u65b9\u6cd5\u4e09\uff1a\u4f7f\u7528expect\u811a\u672c\u6765\u81ea\u52a8\u8f93\u5165\u5bc6\u7801<br> <\/p>\n\n\n\n<p>\u6ce8\uff1a\u5173\u4e8eexpect\u90e8\u5206\u8be6\u7ec6\u8bf7\u53c2\u8003\u300ashell\u7ed3\u5408expect\u5199\u7684\u6279\u91cfscp\u811a\u672c\u5de5\u5177\u300b\uff08\u7701\u7565\uff09<\/p>\n\n\n\n<p>\u603b\u7ed3<br> \u5728\u672c\u6587\u4e2d\u63d0\u4f9b\u4e86\u4e09\u79cd\u65b9\u6cd5\u6765\u5b9e\u73b0scp\u7684\u65f6\u5019\u65e0\u9700\u8f93\u5165\u5bc6\u7801\u7684\u9700\u6c42\uff0c\u4ece\u5b89\u5168\u6027\u548c\u901f\u5ea6\u4e0a\u8003\u8651\u5efa\u7acb\u4fe1\u4efb\u5173\u7cfb\u90fd\u662f\u6700\u4f73\u7684\u65b9\u6cd5\uff0c\u81f3\u4e8e\u5728\u5177\u4f53\u7684\u73af\u5883\u4e2d\u9009\u62e9\u4ec0\u4e48\u5219\u7531\u4f60\u81ea\u5df1\u6765\u51b3\u5b9a\u3002<br> \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014<br> \u7248\u6743\u58f0\u660e\uff1a\u672c\u6587\u4e3aCSDN\u535a\u4e3b\u300cnfer_cn\u300d\u7684\u539f\u521b\u6587\u7ae0\uff0c\u9075\u5faa CC 4.0 BY-SA \u7248\u6743\u534f\u8bae\uff0c\u8f6c\u8f7d\u8bf7\u9644\u4e0a\u539f\u6587\u51fa\u5904\u94fe\u63a5\u53ca\u672c\u58f0\u660e\u3002<br> \u539f\u6587\u94fe\u63a5\uff1a<a href=\"http:\/\/blog.csdn.net\/nfer_zhuang\/article\/details\/42646849\">https:\/\/blog.csdn.net\/nfer_zhuang\/article\/details\/42646849<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u7bc7\u8c08\u8bba\u514d\u5bc6\u7801\u767b\u5f55\uff0c\u5373\u79d8\u94a5\u767b\u5f55\u7684\u5b9e\u73b0\u8fc7\u7a0b\u4ee5\u53ca\u52a0\u5bc6\u539f\u7406<\/p>\n","protected":false},"author":2,"featured_media":675,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[357,253,249],"tags":[366,367,369,368,362,372,370,364,371,363,365],"class_list":["post-584","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-zero2hero","category-fun","category-technology","tag-authentication","tag-authentication_keys","tag-id_rsa","tag-id_rsa-pub","tag-rsa","tag-scp","tag-370","tag-364","tag-371","tag-363","tag-365"],"_links":{"self":[{"href":"https:\/\/blog.zengqq.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/584","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.zengqq.com.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.zengqq.com.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.zengqq.com.cn\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.zengqq.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=584"}],"version-history":[{"count":9,"href":"https:\/\/blog.zengqq.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/584\/revisions"}],"predecessor-version":[{"id":2379,"href":"https:\/\/blog.zengqq.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/584\/revisions\/2379"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.zengqq.com.cn\/index.php?rest_route=\/wp\/v2\/media\/675"}],"wp:attachment":[{"href":"https:\/\/blog.zengqq.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=584"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.zengqq.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=584"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.zengqq.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=584"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}