{"id":1639,"date":"2024-02-26T00:00:00","date_gmt":"2024-02-26T05:00:00","guid":{"rendered":"https:\/\/molecularsciences.org\/content\/?p=1639"},"modified":"2024-02-02T14:37:21","modified_gmt":"2024-02-02T19:37:21","slug":"scp-cheat-sheet","status":"publish","type":"post","link":"https:\/\/molecularsciences.org\/content\/scp-cheat-sheet\/","title":{"rendered":"SCP Cheat Sheet"},"content":{"rendered":"\n<p>SCP (Secure Copy Protocol) is a command-line utility for securely copying files between local and remote hosts. This cheat sheet provides essential SCP commands for efficient file transfers.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Introduction:<\/strong><\/h4>\n\n\n\n<p>SCP, based on the SSH protocol, allows secure and encrypted file transfers between hosts. It is a simple and secure way to copy files and directories over a network.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Copying Files to a Remote Server:<\/strong><\/h4>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Command<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>scp [file] [username]@[hostname]:[destination]<\/code><\/td><td>Copy a file to a remote server.<\/td><\/tr><tr><td><code>scp -P [port] [file] [username]@[hostname]:[destination]<\/code><\/td><td>Specify a custom SSH port for connection.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Copying Directories to a Remote Server:<\/strong><\/h4>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Command<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>scp -r [directory] [username]@[hostname]:[destination]<\/code><\/td><td>Copy a directory and its contents recursively.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Copying Files from a Remote Server:<\/strong><\/h4>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Command<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>scp [username]@[hostname]:[remote_file] [destination]<\/code><\/td><td>Copy a file from a remote server to the local machine.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Preserving File Attributes:<\/strong><\/h4>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Command<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>scp -p [file] [username]@[hostname]:[destination]<\/code><\/td><td>Preserve the original file attributes (permissions, timestamps).<\/td><\/tr><tr><td><code>scp -rp [directory] [username]@[hostname]:[destination]<\/code><\/td><td>Preserve file attributes for directories.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Using SCP with Key-Based Authentication:<\/strong><\/h4>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Command<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>scp -i [private_key] [file] [username]@[hostname]:[destination]<\/code><\/td><td>Specify a private key for authentication.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Displaying Progress Information:<\/strong><\/h4>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Command<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>scp -v [file] [username]@[hostname]:[destination]<\/code><\/td><td>Verbose mode, display detailed information during transfer.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Miscellaneous:<\/strong><\/h4>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Command<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>scp -C [file] [username]@[hostname]:[destination]<\/code><\/td><td>Compress the data during transfer.<\/td><\/tr><tr><td><code>scp --help<\/code><\/td><td>Display SCP command-line options and usage.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Conclusion<\/h3>\n\n\n\n<p>SCP is a straightforward and secure way to copy files between local and remote hosts. This cheat sheet offers a quick reference for common SCP commands, covering file and directory transfers, preserving attributes, and using key-based authentication. Whether you are a system administrator or a developer, mastering these commands will enhance your efficiency in securely transferring files between systems.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>SCP (Secure Copy Protocol) is a command-line utility for securely copying files between local and remote hosts. This cheat sheet provides essential SCP commands for efficient file transfers. Introduction: SCP, based on the SSH protocol, allows secure and encrypted file transfers between hosts. It is a simple and secure way to copy files and directories [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34,265],"tags":[35],"class_list":["post-1639","post","type-post","status-publish","format-standard","hentry","category-linux","category-reference","tag-linux"],"_links":{"self":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/1639","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/comments?post=1639"}],"version-history":[{"count":1,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/1639\/revisions"}],"predecessor-version":[{"id":1640,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/1639\/revisions\/1640"}],"wp:attachment":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/media?parent=1639"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/categories?post=1639"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/tags?post=1639"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}