{"id":11460,"date":"2019-03-14T08:11:30","date_gmt":"2019-03-14T08:11:30","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=11460"},"modified":"2019-03-14T08:11:30","modified_gmt":"2019-03-14T08:11:30","slug":"pscp-transfer-copy-files-to-multiple-linux-servers-using-single-shell","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/14\/pscp-transfer-copy-files-to-multiple-linux-servers-using-single-shell\/","title":{"rendered":"Pscp \u2013 Transfer\/Copy Files to Multiple Linux Servers Using Single Shell"},"content":{"rendered":"<p><strong>Pscp<\/strong>\u00a0utility allows you to transfer\/copy files to multiple remote Linux servers using single terminal with one single command, this tool is a part of\u00a0<strong>Pssh<\/strong>\u00a0(Parallel SSH Tools), which provides parallel versions of OpenSSH and other similar tools such as:<\/p>\n<ol>\n<li><strong>pscp<\/strong>\u00a0\u2013 is utility for copying files in parallel to a number of hosts.<\/li>\n<li><strong>prsync<\/strong>\u00a0\u2013 is a utility for efficiently copying files to multiple hosts in parallel.<\/li>\n<li><strong>pnuke<\/strong>\u00a0\u2013 it helps to kills processes on multiple remote hosts in parallel.<\/li>\n<li><strong>pslurp<\/strong>\u00a0\u2013 it helps to copy files from multiple remote hosts to a central host in parallel.<\/li>\n<\/ol>\n<p>When working in a network environment where there are multiple hosts on the network, a System Administrator may find these tools listed above very useful.<\/p>\n<div id=\"attachment_17500\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/12\/Copy-Files-to-Multiple-Linux-Servers.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-17500\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/12\/Copy-Files-to-Multiple-Linux-Servers.png\" alt=\"Copy Files and Directories to Multiple Linux Servers\" width=\"718\" height=\"341\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Pscp \u2013 Copy Files to Multiple Linux Servers<\/p>\n<\/div>\n<p>In this article, we shall look at some useful examples of\u00a0<strong>Pscp<\/strong>\u00a0utility to transfer\/copy files to multiple Linux hosts on a network.<\/p>\n<p>To use the\u00a0<strong>pscp<\/strong>\u00a0tool, you need to install the PSSH utility on your Linux system, for installation of PSSH you can read this article.<\/p>\n<ol>\n<li><a href=\"https:\/\/www.tecmint.com\/execute-commands-on-multiple-linux-servers-using-pssh\/\" target=\"_blank\" rel=\"noopener\">How to Install Pssh Tool to Execute Commands on Multiple Linux Servers<\/a><\/li>\n<\/ol>\n<p>Almost all the different options used with these tools are the same except for few that are related to the specific functionality of a given utility.<\/p>\n<h3>How to Use Pscp to Transfer\/Copy Files to Multiple Linux Servers<\/h3>\n<p>While using\u00a0<strong>pscp<\/strong>\u00a0you need to create a separate file that includes the number of Linux server IP address and SSH port number that you need to connect to the server.<\/p>\n<h4>Copy Files to Multiple Linux Servers<\/h4>\n<p>Let\u2019s create a new file called \u201c<strong>myscphosts.txt<\/strong>\u201d and add the list of Linux hosts IP address and SSH port (default\u00a0<strong>22<\/strong>) number as shown.<\/p>\n<pre>192.168.0.3:22\r\n192.168.0.9:22\r\n<\/pre>\n<p>Once you\u2019ve added hosts to the file, it\u2019s time to copy files from local machine to multiple Linux hosts under\u00a0<strong>\/tmp<\/strong>directory with the help of following command.<\/p>\n<pre># pscp -h myscphosts.txt -l tecmint -Av wine-1.7.55.tar.bz2 \/tmp\/\r\nOR\r\n# pscp.pssh -h myscphosts.txt -l tecmint -Av wine-1.7.55.tar.bz2 \/tmp\/\r\n<\/pre>\n<h5>Sample Output<\/h5>\n<pre>Warning: do not enter your password if anyone else has superuser\r\nprivileges or access to your account.\r\nPassword: \r\n[1] 17:48:25 [<strong>SUCCESS<\/strong>] 192.168.0.3:22\r\n[2] 17:48:35 [<strong>SUCCESS<\/strong>] 192.168.0.9:22\r\n<\/pre>\n<p>Explanation about the options used in the above command.<\/p>\n<ol>\n<li><strong>-h<\/strong>\u00a0switch used to read a hosts from a given file and location.<\/li>\n<li><strong>-l<\/strong>\u00a0switch reads a default username on all hosts that do not define a specific user.<\/li>\n<li><strong>-A<\/strong>\u00a0switch tells pscp ask for a password and send to ssh.<\/li>\n<li><strong>-v<\/strong>\u00a0switch is used to run pscp in verbose mode.<\/li>\n<\/ol>\n<h4>Copy Directories to Multiple Linux Servers<\/h4>\n<p>If you want to copy entire directory use\u00a0<strong>-r<\/strong>\u00a0option, which will recursively copy entire directories as shown.<\/p>\n<pre># pscp -h myscphosts.txt -l tecmint -Av -r Android\\ Games\/ \/tmp\/\r\nOR\r\n# pscp.pssh -h myscphosts.txt -l tecmint -Av -r Android\\ Games\/ \/tmp\/\r\n<\/pre>\n<h5>Sample Output<\/h5>\n<pre>Warning: do not enter your password if anyone else has superuser\r\nprivileges or access to your account.\r\nPassword: \r\n[1] 17:48:25 [<strong>SUCCESS<\/strong>] 192.168.0.3:22\r\n[2] 17:48:35 [<strong>SUCCESS<\/strong>] 192.168.0.9:22\r\n<\/pre>\n<p>You can view the manual entry page for the\u00a0<strong>pscp<\/strong>\u00a0or use\u00a0<code>pscp --help<\/code>\u00a0command to seek for help.<\/p>\n<h3>Conclusion<\/h3>\n<p>This tool is worth trying as if you control multiple Linux systems and already have\u00a0<a href=\"https:\/\/www.tecmint.com\/ssh-passwordless-login-using-ssh-keygen-in-5-easy-steps\/\" target=\"_blank\" rel=\"noopener\">SSH key-based passwordless login<\/a>\u00a0setup.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/copy-files-to-multiple-linux-servers\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Pscp\u00a0utility allows you to transfer\/copy files to multiple remote Linux servers using single terminal with one single command, this tool is a part of\u00a0Pssh\u00a0(Parallel SSH Tools), which provides parallel versions of OpenSSH and other similar tools such as: pscp\u00a0\u2013 is utility for copying files in parallel to a number of hosts. prsync\u00a0\u2013 is a utility &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/14\/pscp-transfer-copy-files-to-multiple-linux-servers-using-single-shell\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Pscp \u2013 Transfer\/Copy Files to Multiple Linux Servers Using Single Shell&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-11460","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11460","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=11460"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11460\/revisions"}],"predecessor-version":[{"id":11461,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11460\/revisions\/11461"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=11460"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=11460"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=11460"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}