{"id":4589,"date":"2021-04-26T16:42:08","date_gmt":"2021-04-26T13:42:08","guid":{"rendered":"http:\/\/pacpac.ru\/ft-blog\/?p=4589"},"modified":"2024-08-21T01:36:06","modified_gmt":"2024-08-20T22:36:06","slug":"copy-files-over-ssh","status":"publish","type":"post","link":"https:\/\/pacpac.ru\/ft-blog\/2021\/04\/copy-files-over-ssh\/","title":{"rendered":"\u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 SSH"},"content":{"rendered":"<p>\u0427\u0430\u0441\u0442\u043e \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0432 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435 \u0444\u0430\u0439\u043b\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439 \u0438 \u043c\u0430\u0448\u0438\u043d\u043e\u0439, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u0435\u0434\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430. \u041e\u0431\u044b\u0447\u043d\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430 scp \u0438\u0437 \u043f\u0430\u043a\u0435\u0442\u0430 <a href=\"https:\/\/www.openssh.com\/manual.html\">openssh<\/a>. \u042d\u0442\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0432 Linux, Windows 10 \u0438 MacOS.<\/p>\n<p><strong>\u041f\u0440\u0438\u043c\u0435\u0440 1<br \/>\n<\/strong><\/p>\n<p>\u0414\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0444\u0430\u0439\u043b\u0430 payload.txt \u0432 \u043f\u0430\u043f\u043a\u0443 \/tmp \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b target-host:<\/p>\n<p><code>scp payload.txt user@target-host:\/tmp<\/code><\/p>\n<p><strong>\u041f\u0440\u0438\u043c\u0435\u0440 2<br \/>\n<\/strong><\/p>\n<p>\u0414\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430 \/proc\/config.gz \u0438\u0437 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b target-host:<\/p>\n<p><code>scp user@target-host:\/proc\/config.gz config.gz<\/code><\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f\u0445 \u043f\u0440\u044f\u043c\u043e\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435 \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0444\u0430\u0439\u043b\u044b \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0435 \u0443\u0437\u043b\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0432\u044f\u0437\u043a\u0438 ssh \u0438 tar.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u0432\u0432\u043e\u0434\u0438\u0442\u044c \u043f\u0430\u0440\u043e\u043b\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0435 \u043a\u043b\u044e\u0447\u0438 \u043d\u0430 \u0446\u0435\u043b\u0435\u0432\u0443\u044e \u0438 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u0443\u044e \u043c\u0430\u0448\u0438\u043d\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b ssh-copy-id.<\/p>\n<p><strong>\u041f\u0440\u0438\u043c\u0435\u0440 3<br \/>\n<\/strong><\/p>\n<p>\u0414\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0444\u0430\u0439\u043b\u0430 payload.txt \u0432 \u043f\u0430\u043f\u043a\u0443 \/tmp \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b target-host \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0439 \u0443\u0437\u0435\u043b jump-host:<\/p>\n<p><code>tar cf - payload.txt | ssh -J user1@jump-host user2@target-host 'tar x -v -f - -C \/tmp;'<\/code><\/p>\n<p><strong>\u041f\u0440\u0438\u043c\u0435\u0440 3A<br \/>\n<\/strong><\/p>\n<p>\u0414\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0444\u0430\u0439\u043b\u0430 payload.txt \u0432 \u043f\u0430\u043f\u043a\u0443 \/tmp \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b target-host \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0439 \u0443\u0437\u0435\u043b jump-host:<\/p>\n<p><code>scp -o ProxyJump=user1@jump-host payload.txt user2@target-host:\/tmp<\/code><\/p>\n<p><strong>\u041f\u0440\u0438\u043c\u0435\u0440 4<br \/>\n<\/strong><\/p>\n<p>\u0414\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430 \/proc\/config.gz \u0438\u0437 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b target-host \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0439 \u0443\u0437\u0435\u043b jump-host:<\/p>\n<p><code>ssh -J user1@jump-host user2@target-host 'tar cf - -\u0421 \/proc config.gz' | tar x -v -f -<\/code><\/p>\n<p>\u041a\u0441\u0442\u0430\u0442\u0438, \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0445 \u0443\u0437\u043b\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u0434\u043d\u043e\u0433\u043e.<\/p>\n<p><strong>\u0421\u043f\u0438\u0441\u043e\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432 \u0438 \u043b\u0438\u0442\u0435\u0440\u0430\u0442\u0443\u0440\u044b<\/strong><\/p>\n<p>1. <a href=\"https:\/\/man.openbsd.org\/scp\">scp \u2014 OpenSSH secure file copy<\/a><\/p>\n<p>2. <a href=\"https:\/\/man.openbsd.org\/ssh\">ssh \u2014 OpenSSH remote login client <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0427\u0430\u0441\u0442\u043e \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0432 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435 \u0444\u0430\u0439\u043b\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439 \u0438 \u043c\u0430\u0448\u0438\u043d\u043e\u0439, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u0435\u0434\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430. \u041e\u0431\u044b\u0447\u043d\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430 scp \u0438\u0437 \u043f\u0430\u043a\u0435\u0442\u0430 openssh. \u042d\u0442\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0432 Linux, Windows 10 \u0438 MacOS. \u041f\u0440\u0438\u043c\u0435\u0440 1 \u0414\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0444\u0430\u0439\u043b\u0430 payload.txt \u0432 \u043f\u0430\u043f\u043a\u0443 \/tmp \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b target-host: scp payload.txt user@target-host:\/tmp \u041f\u0440\u0438\u043c\u0435\u0440 2 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[17,49],"tags":[188,134,93],"_links":{"self":[{"href":"https:\/\/pacpac.ru\/ft-blog\/wp-json\/wp\/v2\/posts\/4589"}],"collection":[{"href":"https:\/\/pacpac.ru\/ft-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pacpac.ru\/ft-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pacpac.ru\/ft-blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/pacpac.ru\/ft-blog\/wp-json\/wp\/v2\/comments?post=4589"}],"version-history":[{"count":11,"href":"https:\/\/pacpac.ru\/ft-blog\/wp-json\/wp\/v2\/posts\/4589\/revisions"}],"predecessor-version":[{"id":5438,"href":"https:\/\/pacpac.ru\/ft-blog\/wp-json\/wp\/v2\/posts\/4589\/revisions\/5438"}],"wp:attachment":[{"href":"https:\/\/pacpac.ru\/ft-blog\/wp-json\/wp\/v2\/media?parent=4589"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pacpac.ru\/ft-blog\/wp-json\/wp\/v2\/categories?post=4589"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pacpac.ru\/ft-blog\/wp-json\/wp\/v2\/tags?post=4589"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}