{"id":135409,"date":"2019-02-01T08:29:19","date_gmt":"2019-02-01T00:29:19","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=135409"},"modified":"2019-01-30T09:31:34","modified_gmt":"2019-01-30T01:31:34","slug":"cli-scp","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/cli-scp.html","title":{"rendered":"\u5229\u7528scp \u8fdc\u7a0b\u4e0a\u4f20\u4e0b\u8f7d\u6587\u4ef6\/\u6587\u4ef6\u5939"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nscp\u662fsecure copy\u7684\u7b80\u5199\uff0c\u7528\u4e8e\u5728Linux\u4e0b\u8fdb\u884c\u8fdc\u7a0b\u62f7\u8d1d\u6587\u4ef6\u7684\u547d\u4ee4\uff0c\u548c\u5b83\u7c7b\u4f3c\u7684\u547d\u4ee4\u6709cp\uff0c\u4e0d\u8fc7cp\u53ea\u662f\u5728\u672c\u673a\u8fdb\u884c\u62f7\u8d1d\u4e0d\u80fd\u8de8\u670d\u52a1\u5668\uff0c\u800c\u4e14scp\u4f20\u8f93\u662f\u52a0\u5bc6\u7684\u3002\u53ef\u80fd\u4f1a\u7a0d\u5fae\u5f71\u54cd\u4e00\u4e0b\u901f\u5ea6\u3002\u5f53\u4f60\u670d\u52a1\u5668\u786c\u76d8\u53d8\u4e3a\u53ea\u8bfb read only system\u65f6\uff0c\u7528scp\u53ef\u4ee5\u5e2e\u4f60\u628a\u6587\u4ef6\u79fb\u51fa\u6765\u3002\u53e6\u5916\uff0cscp\u8fd8\u975e\u5e38\u4e0d\u5360\u8d44\u6e90\uff0c\u4e0d\u4f1a\u63d0\u9ad8\u591a\u5c11\u7cfb\u7edf\u8d1f\u8377\uff0c\u5728\u8fd9\u4e00\u70b9\u4e0a\uff0crsync\u5c31\u8fdc\u8fdc\u4e0d\u53ca\u5b83\u4e86\u3002\u867d\u7136 rsync\u6bd4scp\u4f1a\u5feb\u4e00\u70b9\uff0c\u4f46\u5f53\u5c0f\u6587\u4ef6\u4f17\u591a\u7684\u60c5\u51b5\u4e0b\uff0crsync\u4f1a\u5bfc\u81f4\u786c\u76d8I\/O\u975e\u5e38\u9ad8\uff0c\u800cscp\u57fa\u672c\u4e0d\u5f71\u54cd\u7cfb\u7edf\u6b63\u5e38\u4f7f\u7528\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"\"<\/p>\n

1\uff0e\u547d\u4ee4\u683c\u5f0f<\/strong><\/div>\n

scp\u00a0[\u53c2\u6570]\u00a0[\u539f\u8def\u5f84]\u00a0[\u76ee\u6807\u8def\u5f84]<\/p>\n

\u547d\u4ee4\u529f\u80fd<\/strong><\/span><\/div>\n

scp\u662f secure copy\u7684\u7f29\u5199, scp\u662flinux\u7cfb\u7edf\u4e0b\u57fa\u4e8essh\u767b\u9646\u8fdb\u884c\u5b89\u5168\u7684\u8fdc\u7a0b\u6587\u4ef6\u62f7\u8d1d\u547d\u4ee4\u3002linux\u7684scp\u547d\u4ee4\u53ef\u4ee5\u5728linux\u670d\u52a1\u5668\u4e4b\u95f4\u590d\u5236\u6587\u4ef6\u548c\u76ee\u5f55\u3002<\/p>\n

\u547d\u4ee4\u53c2\u6570<\/strong><\/span><\/div>\n
-1\u00a0 \u5f3a\u5236scp\u547d\u4ee4\u4f7f\u7528\u534f\u8baessh1\r\n\r\n-2\u00a0 \u5f3a\u5236scp\u547d\u4ee4\u4f7f\u7528\u534f\u8baessh2\r\n\r\n-4\u00a0 \u5f3a\u5236scp\u547d\u4ee4\u53ea\u4f7f\u7528IPv4\u5bfb\u5740\r\n\r\n-6\u00a0 \u5f3a\u5236scp\u547d\u4ee4\u53ea\u4f7f\u7528IPv6\u5bfb\u5740\r\n\r\n-B\u00a0 \u4f7f\u7528\u6279\u5904\u7406\u6a21\u5f0f\uff08\u4f20\u8f93\u8fc7\u7a0b\u4e2d\u4e0d\u8be2\u95ee\u4f20\u8f93\u53e3\u4ee4\u6216\u77ed\u8bed\uff09\r\n\r\n-C\u00a0 \u5141\u8bb8\u538b\u7f29\u3002\uff08\u5c06-C\u6807\u5fd7\u4f20\u9012\u7ed9ssh\uff0c\u4ece\u800c\u6253\u5f00\u538b\u7f29\u529f\u80fd\uff09\r\n\r\n-p \u4fdd\u7559\u539f\u6587\u4ef6\u7684\u4fee\u6539\u65f6\u95f4\uff0c\u8bbf\u95ee\u65f6\u95f4\u548c\u8bbf\u95ee\u6743\u9650\u3002\r\n\r\n-q\u00a0 \u4e0d\u663e\u793a\u4f20\u8f93\u8fdb\u5ea6\u6761\u3002\r\n\r\n-r\u00a0 \u9012\u5f52\u590d\u5236\u6574\u4e2a\u76ee\u5f55\u3002\r\n\r\n-v \u8be6\u7ec6\u65b9\u5f0f\u663e\u793a\u8f93\u51fa\u3002scp\u548cssh(1)\u4f1a\u663e\u793a\u51fa\u6574\u4e2a\u8fc7\u7a0b\u7684\u8c03\u8bd5\u4fe1\u606f\u3002\u8fd9\u4e9b\u4fe1\u606f\u7528\u4e8e\u8c03\u8bd5\u8fde\u63a5\uff0c\u9a8c\u8bc1\u548c\u914d\u7f6e\u95ee\u9898\u3002\r\n\r\n-c cipher\u00a0 \u4ee5cipher\u5c06\u6570\u636e\u4f20\u8f93\u8fdb\u884c\u52a0\u5bc6\uff0c\u8fd9\u4e2a\u9009\u9879\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9ssh\u3002\r\n\r\n-F ssh_config\u00a0 \u6307\u5b9a\u4e00\u4e2a\u66ff\u4ee3\u7684ssh\u914d\u7f6e\u6587\u4ef6\uff0c\u6b64\u53c2\u6570\u76f4\u63a5\u4f20\u9012\u7ed9ssh\u3002\r\n\r\n-i identity_file\u00a0 \u4ece\u6307\u5b9a\u6587\u4ef6\u4e2d\u8bfb\u53d6\u4f20\u8f93\u65f6\u4f7f\u7528\u7684\u5bc6\u94a5\u6587\u4ef6\uff0c\u6b64\u53c2\u6570\u76f4\u63a5\u4f20\u9012\u7ed9ssh\u3002\r\n\r\n-l limit\u00a0 \u9650\u5b9a\u7528\u6237\u6240\u80fd\u4f7f\u7528\u7684\u5e26\u5bbd\uff0c\u4ee5Kbit\/s\u4e3a\u5355\u4f4d\u3002\r\n\r\n-o ssh_option\u00a0 \u5982\u679c\u4e60\u60ef\u4e8e\u4f7f\u7528ssh_config(5)\u4e2d\u7684\u53c2\u6570\u4f20\u9012\u65b9\u5f0f\uff0c\r\n\r\n-P port\u00a0 \u6ce8\u610f\u662f\u5927\u5199\u7684P, port\u662f\u6307\u5b9a\u6570\u636e\u4f20\u8f93\u7528\u5230\u7684\u7aef\u53e3\u53f7\r\n\r\n-S program\u00a0 \u6307\u5b9a\u52a0\u5bc6\u4f20\u8f93\u65f6\u6240\u4f7f\u7528\u7684\u7a0b\u5e8f\u3002\u6b64\u7a0b\u5e8f\u5fc5\u987b\u80fd\u591f\u7406\u89e3ssh(1)\u7684\u9009\u9879\u3002\r\n<\/pre>\n
2\u3001\u4ece\u670d\u52a1\u5668\u4e0b\u8f7d\u6587\u4ef6<\/strong><\/div>\n
scp username@servername:\/path\/filename \/tmp\/local_destination<\/pre>\n

\u4f8b\u5982scp root@192.168.0.101:\/home\/kimi\/test.txt<\/p>\n

\u628a192.168.0.101\u4e0a\u7684\/home\/kimi\/test.txt\u7684\u6587\u4ef6\u4e0b\u8f7d\u5230 \/tmp\/local_destination<\/p>\n

3\u3001\u4e0a\u4f20\u672c\u5730\u6587\u4ef6\u5230\u670d\u52a1\u5668<\/strong><\/div>\n
scp \/path\/local_filename username@servername:\/path<\/pre>\n

\u4f8b\u5982scp \/var\/www\/test.php root@192.168.0.101:\/var\/www\/ \u628a\u672c\u673a\/var\/www\/\u76ee\u5f55\u4e0b\u7684test.php\u6587\u4ef6
\n\u4e0a\u4f20\u5230192.168.0.101\u8fd9\u53f0\u670d\u52a1\u5668\u4e0a\u7684\/var\/www\/\u76ee\u5f55\u4e2d<\/p>\n

4\u3001\u4ece\u670d\u52a1\u5668\u4e0b\u8f7d\u6574\u4e2a\u76ee\u5f55<\/strong><\/div>\n
scp -r username@servername:remote_dir\/ \/tmp\/local_dir<\/pre>\n

\u4f8b\u5982:scp -r root@192.168.0.101 \/home\/kimi\/test \/tmp\/local_dir<\/p>\n

5\u3001\u4e0a\u4f20\u76ee\u5f55\u5230\u670d\u52a1\u5668<\/strong><\/div>\n
scp -r \/tmp\/local_dir username@servername:remote_dir<\/pre>\n

\u4f8b\u5982\uff1ascp -r test root@192.168.0.101:\/var\/www\/ \u628a\u5f53\u524d\u76ee\u5f55\u4e0b\u7684test\u76ee\u5f55\u4e0a\u4f20\u5230\u670d\u52a1\u5668\u7684\/var\/www\/ \u76ee\u5f55<\/p>\n","protected":false},"excerpt":{"rendered":"

scp\u00a0[\u53c2\u6570]\u00a0[\u539f\u8def\u5f84]\u00a0[\u76ee\u6807\u8def\u5f84] scp\u662f secure copy\u7684\u7f29\u5199, scp\u662flinux\u7cfb\u7edf\u4e0b […]<\/p>\n","protected":false},"author":362,"featured_media":135417,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-135409","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/135409","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/362"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=135409"}],"version-history":[{"count":10,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/135409\/revisions"}],"predecessor-version":[{"id":135487,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/135409\/revisions\/135487"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/135417"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=135409"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=135409"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=135409"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}