{"id":2183,"date":"2012-03-10T23:55:46","date_gmt":"2012-03-10T15:55:46","guid":{"rendered":"https:\/\/webhostinggeeks.com\/howto\/?p=2183"},"modified":"2023-04-28T09:49:41","modified_gmt":"2023-04-28T09:49:41","slug":"transfer-files-between-servers-linux","status":"publish","type":"post","link":"https:\/\/webhostinggeeks.com\/howto\/transfer-files-between-servers-linux\/","title":{"rendered":"Transfer Files Between Servers in Linux"},"content":{"rendered":"<p>SSH File Transfer Protocol also called Secret File Transfer Protocol or Secure FTP, or SFTP is a network protocol that provides file access, file transfer, and file management functionality over the network. In this post i will show how to transfer the files using sftp command on Linux Red Hat Enterprise Linux 6 (RHEL 6). Assumed that the following servers presented on your network.<\/p>\n<p>Transfer Files Between Servers using sftp Command<\/p>\n<p>rhel 6 = 192.168.2.43 &#8211;> Local working directory: \/root\/rhel6<br \/>\nCentOS 5.7 = 192.168.2.45 &#8211;> Remote working directory: \/root\/centos57<\/p>\n<p>1. From local working directory rhel6, sftp to centos57 (192.168.2.45) using root with password as below :<\/p>\n<pre>\n[root@rhel6 ~]# sftp root@192.168.2.45\nConnecting to 192.168.2.45...\nThe authenticity of host '192.168.2.45 (192.168.2.45)' can't be established.\nRSA key fingerprint is 59:4a:13:85:f0:60:9d:c1:1d:49:95:c7:58:56:5d:4c.\nAre you sure you want to continue connecting (yes\/no)? yes\nWarning: Permanently added '192.168.2.45' (RSA) to the list of known hosts.\nroot@192.168.2.45's password:\n<\/pre>\n<p>2. Change the directory on the local computer using lcd command. In this case i will Change the directory to \/root\/rhel6 :<\/p>\n<pre>\nsftp> lcd \/root\/rhel6\n<\/pre>\n<p>3. Show the current directory (present working directory) on the local computer. In this case local working directory is \/root\/rhel6 :<\/p>\n<pre>\nsftp> lpwd\nLocal working directory: \/root\/rhel6\n<\/pre>\n<p>Display local directory listing<\/p>\n<pre>\nsftp> lls\ntesting.tar.gz\n<\/pre>\n<p>4. Copy\/upload a file from the local computer to the remote computer using put command. This scenario consider equivalent with uploading process. At first, only testfile1 and testfile2 exist in \/root\/centos57. In this case, i will copy the testing.tar.gz from \/root\/rhel6 to \/root\/centos57 :<\/p>\n<pre>\nsftp> put testing.tar.gz\nUploading testing.tar.gz to \/root\/centos57\/testing.tar.gz\ntesting.tar.gz                                                    100%  169     0.2KB\/s   00:00\n<\/pre>\n<p>Display remote working directory :<\/p>\n<pre>\nsftp> pwd\nRemote working directory: \/root\/centos57\n<\/pre>\n<p>Display remote directory listing :<\/p>\n<pre>\nsftp> ls\ntestfile1       testfile2       testing.tar.gz\n<\/pre>\n<p>5. Change the directory on the remote computer using cd command. In this case i will Change the directory to \/root\/centos57 :<\/p>\n<pre>\nsftp> cd \/root\/centos57\n<\/pre>\n<p>6. Show the current directory (present working directory) on the remote server. In this case remote working directory is \/root\/centos57 :<\/p>\n<pre>\nsftp> pwd\nRemote working directory: \/root\/centos57\n<\/pre>\n<p>Display remote directory listing :<\/p>\n<pre>\nsftp> ls\ntestfile1  testfile2\n<\/pre>\n<p>7. Copy\/download a file from the remote computer to the local computer using get command. This scenario consider same as downloading process. At first, only testing.tar.gz exist in \/root\/rhel6. In this case, i will copy the testfile1 from \/root\/centos57 to \/root\/rhel6 :<\/p>\n<pre>\nsftp> get testfile1\nFetching \/root\/centos57\/testfile1 to testfile1\n\/root\/centos57\/testfile1                                          100%    5     0.0KB\/s   00:00\n<\/pre>\n<p>Display local working directory :<\/p>\n<pre>\nsftp> lpwd\nLocal working directory: \/root\/rhel6\n<\/pre>\n<p>Display local directory listing :<\/p>\n<pre>\nsftp> lls\ntestfile1  testing.tar.gz\nsftp>\n<\/pre>\n<p>8. Display this help text :<\/p>\n<pre>\nsftp> help\nAvailable commands:\nbye                                Quit sftp\ncd path                            Change remote directory to 'path'\nchgrp grp path                     Change group of file 'path' to 'grp'\nchmod mode path                    Change permissions of file 'path' to 'mode'\nchown own path                     Change owner of file 'path' to 'own'\ndf [-hi] [path]                    Display statistics for current directory or\n                                   filesystem containing 'path'\nexit                               Quit sftp\nget [-P] remote-path [local-path]  Download file\nhelp                               Display this help text\nlcd path                           Change local directory to 'path'\nlls [ls-options [path]]            Display local directory listing\nlmkdir path                        Create local directory\nln oldpath newpath                 Symlink remote file\nlpwd                               Print local working directory\nls [-1aflnrSt] [path]              Display remote directory listing\nlumask umask                       Set local umask to 'umask'\nmkdir path                         Create remote directory\nprogress                           Toggle display of progress meter\nput [-P] local-path [remote-path]  Upload file\npwd                                Display remote working directory\nquit                               Quit sftp\nrename oldpath newpath             Rename remote file\nrm path                            Delete remote file\nrmdir path                         Remove remote directory\nsymlink oldpath newpath            Symlink remote file\nversion                            Show SFTP version\n!command                           Execute 'command' in local shell\n!                                  Escape to local shell\n?                                  Synonym for help\nsftp>\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>SSH File Transfer Protocol also called Secret File Transfer Protocol or Secure FTP, or SFTP is a network protocol that provides file access, file transfer, and file management functionality over&#8230;<\/p>\n","protected":false},"author":6,"featured_media":1499,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wds_primary_category":0,"footnotes":""},"categories":[2063],"tags":[1399,1536,1546,1682,1713,1715,1778],"class_list":["post-2183","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ftp","tag-get-command","tag-linux","tag-linux-utilities","tag-put-command","tag-rhel","tag-rhel-6","tag-sftp"],"_links":{"self":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/2183","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/comments?post=2183"}],"version-history":[{"count":0,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/2183\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media\/1499"}],"wp:attachment":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media?parent=2183"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/categories?post=2183"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/tags?post=2183"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}