{"id":221783,"date":"2021-07-05T08:55:16","date_gmt":"2021-07-05T00:55:16","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=221783"},"modified":"2021-06-29T15:55:40","modified_gmt":"2021-06-29T07:55:40","slug":"scp-cmd-usage","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/scp-cmd-usage.html","title":{"rendered":"scp\u547d\u4ee4\u4f7f\u7528\u65b9\u6cd5"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nscp \u547d\u4ee4\u662f\u7528\u4e8e\u901a\u8fc7 SSH \u534f\u8bae\u5b89\u5168\u5730\u5c06\u6587\u4ef6\u590d\u5236\u5230\u8fdc\u7a0b\u7cfb\u7edf\u548c\u4ece\u8fdc\u7a0b\u7cfb\u7edf\u590d\u5236\u6587\u4ef6\u5230\u672c\u5730\u7684\u547d\u4ee4\u3002\u4f7f\u7528 SSH \u610f\u5473\u7740\u5b83\u4eab\u6709\u4e0e SSH \u76f8\u540c\u7ea7\u522b\u7684\u6570\u636e\u52a0\u5bc6\uff0c\u56e0\u6b64\u88ab\u8ba4\u4e3a\u662f\u8de8\u4e24\u4e2a\u8fdc\u7a0b\u4e3b\u673a\u4f20\u8f93\u6587\u4ef6\u7684\u5b89\u5168\u65b9\u5f0f\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u57fa\u672c\u8bed\u6cd5<\/strong><\/div>\n

\u4e0b\u9762\u63d0\u4f9b\u4e86 SCP \u547d\u4ee4\u7684\u57fa\u672c\u8bed\u6cd5\uff1a<\/p>\n

\r\n$ scp [option] \/path\/to\/source\/file user@server-ip:\/path\/to\/destination\/directory\r\n<\/pre>\n

\/path\/to\/source\/file<\/code> \u2013 \u8fd9\u662f\u6253\u7b97\u590d\u5236\u5230\u8fdc\u7a0b\u4e3b\u673a\u7684\u6e90\u6587\u4ef6\u3002<\/p>\n

user@server-IP:<\/code> \u2013 \u8fd9\u662f\u8fdc\u7a0b\u7cfb\u7edf\u7684\u7528\u6237\u540d\u548c IP \u5730\u5740\u3002\u8bf7\u6ce8\u610f IP \u5730\u5740\u540e\u9762\u52a0\u5192\u53f7\u3002<\/p>\n

\/path\/to\/destination\/directory<\/code> \u2013 \u8fd9\u662f\u6587\u4ef6\u5c06\u590d\u5236\u5230\u7684\u8fdc\u7a0b\u7cfb\u7edf\u4e0a\u7684\u76ee\u6807\u76ee\u5f55\u3002<\/p>\n

\u4ee5\u4e0b\u662fscp\u547d\u4ee4\u5e38\u7528\u7684\u51e0\u4e2a\u9009\u9879\uff1a<\/p>\n

    \n
  • -C<\/code> - \u8fd9\u4f1a\u5728\u590d\u5236\u8fc7\u7a0b\u4e2d\u538b\u7f29\u6587\u4ef6\u6216\u76ee\u5f55\u3002<\/li>\n
  • -P<\/code> - \u5982\u679c\u9ed8\u8ba4 SSH \u7aef\u53e3\u4e0d\u662f 22\uff0c\u5219\u4f7f\u7528\u6b64\u9009\u9879\u6307\u5b9a SSH \u7aef\u53e3\u3002<\/li>\n
  • -r<\/code> - \u6b64\u9009\u9879\u9012\u5f52\u590d\u5236\u76ee\u5f55\u53ca\u5176\u5185\u5bb9\u3002<\/li>\n
  • -p<\/code> - \u4fdd\u7559\u6587\u4ef6\u7684\u8bbf\u95ee\u548c\u4fee\u6539\u65f6\u95f4\u3002<\/li>\n<\/ul>\n
    \u5c06\u6587\u4ef6\u590d\u5236\u5230\u8fdc\u7a0b Linux \u670d\u52a1\u5668<\/strong><\/div>\n

    \u5728\u4e0b\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u6211\u5c06logs.tar.gz \u590d\u5236\u5230\u8fdc\u7a0b\u4e3b\u673a\u7684\/root\u76ee\u5f55\u4e0b\u3002\u4e3b\u673aIP\u4e3a192.168.43.137\uff0c\u7528\u6237\u540d\u4e3aroot\u3002<\/p>\n

    \r\n[root@server1 ~]# scp logs.tar.gz root@192.168.43.137:\/root\r\n<\/pre>\n

    \"\"
    \n\u5982\u679c\u8981\u590d\u5236\u76ee\u5f55\uff0c\u8bf7\u4f7f\u7528-r<\/code>\u9009\u9879\uff0c\u5982\u4e0b\u6240\u793a\u3002\u5728\u8fd9\u91cc\uff0c\u6211\u4eec\u5c06 \/root\/syslog\u76ee\u5f55\u590d\u5236\u5230\u8fdc\u7a0b\u8282\u70b9\u7684\/root\u76ee\u5f55\u4e2d\u3002<\/p>\n

    \r\n[root@server1 ~]# scp -r syslog root@192.168.43.137:\/root\r\n<\/pre>\n

    \"\"
    \n\u5982\u679c\u4e0d\u6dfb\u52a0-r<\/code>\u9009\u9879\u590d\u5236\u76ee\u5f55\uff0c\u4f1a\u63d0\u793a\u5982\u4e0b\u9519\u8bef\u3002<\/p>\n

    \r\n[root@server1 ~]# scp syslog root@192.168.43.137:\/root\r\nroot@192.168.43.137's password: \r\nsyslog: not a regular file\r\n<\/pre>\n

    \"\"<\/p>\n

    \u5c06\u6587\u4ef6\u4ece\u8fdc\u7a0b\u7cfb\u7edf\u590d\u5236\u5230\u672c\u5730\u7cfb\u7edf<\/strong><\/div>\n

    \u53ef\u4ee5\u5c06\u6587\u4ef6\u4ece\u8fdc\u7a0b\u8282\u70b9\u590d\u5236\u5230\u672c\u5730\u7cfb\u7edf\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n

    \r\n$ scp [option] user@server-ip:\/path\/to\/source\/file\/path\/to\/local\/directory\r\n<\/pre>\n

    \u5728\u4e0b\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u5c06\u6587\u4ef6 \/root\/passwd<\/code>\u4ece\u8fdc\u7a0b\u7cfb\u7edf\u590d\u5236\u5230\u672c\u5730\u7cfb\u7edf\uff1a<\/p>\n

    \r\n[root@server1 ~]# scp root@192.168.43.137:\/root\/passwd \/root\/\r\n<\/pre>\n

    \"\"
    \n\u540c\u6837\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528-r<\/code>\u6807\u5fd7\u5c06\u76ee\u5f55\u4ece\u8fdc\u7a0b\u4e3b\u673a\u590d\u5236\u5230\u672c\u5730\u7cfb\u7edf\uff0c\u5982\u56fe\u6240\u793a\u3002<\/p>\n

    \r\n[root@server1 ~]# scp -r root@192.168.43.137:\/root\/scripts \/root\/\r\n<\/pre>\n

    \"\"
    \n\u6709\u5173\u4f7f\u7528 scp<\/code> \u547d\u4ee4\u7684\u66f4\u591a\u9009\u9879\uff0c\u53ef\u4ee5\u67e5\u770b\u624b\u518c\uff0c\u547d\u4ee4\u662f\uff1aman scp<\/code>
    \n\"\"<\/p>\n

    \u603b\u7ed3<\/strong><\/div>\n

    Linux SCP \u547d\u4ee4\u662f\u4e00\u79cd\u5728\u4e24\u4e2a\u8fdc\u7a0b\u8282\u70b9\u4e4b\u95f4\u4f20\u8f93\u6587\u4ef6\u7684\u4fbf\u6377\u4e14\u5b89\u5168\u7684\u65b9\u5f0f\uff0c\u800c\u65e0\u9700\u62c5\u5fc3\u653b\u51fb\u8005\u7aa5\u63a2\u4f60\u7684\u6570\u636e\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

    \u4e0b\u9762\u63d0\u4f9b\u4e86 SCP \u547d\u4ee4\u7684\u57fa\u672c\u8bed\u6cd5\uff1a $ scp [option] \/path\/to\/source\/file […]<\/p>\n","protected":false},"author":309,"featured_media":221785,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-221783","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\/221783","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\/309"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=221783"}],"version-history":[{"count":1,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/221783\/revisions"}],"predecessor-version":[{"id":221791,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/221783\/revisions\/221791"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/221785"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=221783"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=221783"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=221783"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}