{"id":5649,"date":"2023-12-08T10:54:59","date_gmt":"2023-12-08T10:54:59","guid":{"rendered":"https:\/\/natsav.com\/blog\/?p=5649"},"modified":"2024-02-14T12:42:49","modified_gmt":"2024-02-14T12:42:49","slug":"use-of-scp-command","status":"publish","type":"post","link":"https:\/\/natsav.com\/blog\/use-of-scp-command\/","title":{"rendered":"How To Move Files on Servers With Help of SCP Command &#038; Use of SCP Command"},"content":{"rendered":"<p><span style=\"color: #000000;\"><span style=\"text-decoration: underline;\"><strong>Step 1: Copying a file from local machine to a remote server<\/strong><\/span>.<\/span><br \/>\n# [ scp \/path\/to\/local\/file.txt user@remote_server:\/path\/to\/destination\/ ]<br \/>\nReplace &#8220;\/path\/to\/local\/file.txt&#8221; with the actual path of the file on your local machine, user with your remote server username, remote_server with the IP address or hostname of the remote server, and &#8220;\/path\/to\/destination\/&#8221; with the destination path on the remote server.<\/p>\n<p><span style=\"text-decoration: underline; color: #000000;\"><strong>Step 2: Copying a file from a remote server to the local machine<\/strong><\/span><strong><span style=\"color: #000000;\">.<\/span><br \/>\n<\/strong># [ scp user@remote_server:\/path\/to\/remote\/file.txt \/path\/to\/local\/destination\/ ]<br \/>\nThis example retrieves a file from the remote server and saves it to the specified local destination.<\/p>\n<p><span style=\"color: #000000;\"><span style=\"text-decoration: underline;\"><strong>Step 3: Copying an entire directory from local to remote<\/strong><\/span>.<\/span><br \/>\n# [ scp -r \/path\/to\/local\/directory\/ user@remote_server:\/path\/to\/destination\/ ]<br \/>\nThe -r flag is used for recursive copying of directories.<\/p>\n<p><span style=\"color: #000000;\"><span style=\"text-decoration: underline;\"><strong>Step 4: Copying from remote to local with compression<\/strong><\/span>.<\/span><br \/>\n# [ scp -C -r user@remote_server:\/path\/to\/remote\/directory\/ \/path\/to\/local\/destination\/ ]<br \/>\nThe -C flag enables compression during the transfer, which can be useful for large files.<\/p>\n<p><span style=\"color: #000000;\"><span style=\"text-decoration: underline;\"><strong>Step 5: Copying multiple files from local to remote<\/strong><\/span>.<\/span><br \/>\n# [ scp file1.txt file2.txt user@remote_server:\/path\/to\/destination\/ ]<br \/>\nYou can list multiple source files to be copied.<\/p>\n<p><span style=\"color: #000000;\"><span style=\"text-decoration: underline;\"><strong>Step 6: Using a specific SSH key<\/strong><\/span>.<\/span><br \/>\n# [ scp -i \/path\/to\/private\/key.pem \/path\/to\/local\/file.txt user@remote_server:\/path\/to\/destination\/ ]<br \/>\nUse the -i option to specify the path to your private key.<\/p>\n<p><span style=\"color: #000000;\"><span style=\"text-decoration: underline;\"><strong>Note<\/strong><\/span>:<\/span>\u00a0 a)\u00a0 Make sure you have the necessary permissions to access the source and destination directories\/files.<br \/>\nb) Ensure that SSH is set up on both servers, and you can log in without a password (use SSH keys for secure authentication).<br \/>\nc) Adjust file paths, usernames, and server addresses according to your setup.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Step 1: Copying a file from local machine to a remote server. # [ scp \/path\/to\/local\/file.txt user@remote_server:\/path\/to\/destination\/ ] Replace &#8220;\/path\/to\/local\/file.txt&#8221; with the actual path of the file on your local machine, user with your remote server username, remote_server with the IP address or hostname of the remote server, and &#8220;\/path\/to\/destination\/&#8221; with the destination path on [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":5657,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[258],"tags":[],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/i0.wp.com\/natsav.com\/blog\/wp-content\/uploads\/2023\/12\/SCP-e1702032895950.png?fit=705%2C247&ssl=1","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/posts\/5649"}],"collection":[{"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/comments?post=5649"}],"version-history":[{"count":5,"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/posts\/5649\/revisions"}],"predecessor-version":[{"id":5890,"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/posts\/5649\/revisions\/5890"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/media\/5657"}],"wp:attachment":[{"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/media?parent=5649"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/categories?post=5649"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/tags?post=5649"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}