{"id":12316,"date":"2026-03-06T10:00:01","date_gmt":"2026-03-06T04:30:01","guid":{"rendered":"https:\/\/www.youstable.com\/blog\/?p=12316"},"modified":"2026-03-06T10:00:17","modified_gmt":"2026-03-06T04:30:17","slug":"scp-command-in-linux","status":"publish","type":"post","link":"https:\/\/www.youstable.com\/blog\/scp-command-in-linux","title":{"rendered":"SCP command in Linux | Complete User Guide with Examples 2026"},"content":{"rendered":"\n<p><strong>The SCP command in Linux<\/strong> securely copies files and directories between local and remote systems over SSH. It encrypts data in transit, supports keys and custom ports, and works with simple syntax like <code>scp source target<\/code>. Use it to transfer backups, configs, or web assets to servers quickly, with options for recursion, throttling, compression, and jump hosts.<\/p>\n\n\n\n<p>If you <strong>manage servers<\/strong> or deploy websites, learning the SCP command in Linux saves time and keeps transfers secure. In this practical user guide, I\u2019ll explain how SCP works, its syntax, reliable examples, security best practices, and pro tips from 12+ years running Linux, cloud, and hosting environments at scale (including YouStable\u2019s infrastructure).<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"what-is-scp-and-how-does-it-work\">What is SCP and How Does it Work?<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"2848\" height=\"1600\" src=\"https:\/\/www.youstable.com\/blog\/wp-content\/uploads\/2025\/12\/image-27.png\" alt=\"What Is SCP and How Does It Work?\" class=\"wp-image-12466\" srcset=\"https:\/\/www.youstable.com\/blog\/wp-content\/uploads\/2025\/12\/image-27.png 2848w, https:\/\/www.youstable.com\/blog\/wp-content\/uploads\/2025\/12\/image-27-150x84.png 150w\" sizes=\"auto, (max-width: 2848px) 100vw, 2848px\" \/><\/figure>\n\n\n\n<p>SCP (Secure Copy) is a command line utility that copies files between hosts using SSH for authentication and encryption. By default, it connects to TCP port 22 and supports <a href=\"https:\/\/www.youstable.com\/blog\/ssh-keys-vs-password-authentication\/\">passwords or SSH keys<\/a>. Modern OpenSSH versions use the SFTP protocol under the hood for safer path handling, but the scp command and its familiar syntax remain available.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Encrypted in transit (same crypto and keys as SSH)<\/li>\n\n\n\n<li>Works local to remote, remote to local, and remote to remote<\/li>\n\n\n\n<li>Simple, predictable syntax with options for recursion, ports, bandwidth limits, compression, and jump hosts<\/li>\n\n\n\n<li>Ideal for quick, one off transfers; for syncs\/resume features, consider rsync<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"scp-syntax-explained-in-60-seconds\">SCP Syntax (Explained in 60 Seconds)<\/h2>\n\n\n\n<p><strong>The basic format is:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>scp &#91;options] source target\nscp &#91;options] &#91;&#91;user@]host1:]path1 &#91;&#91;user@]host2:]path2<\/code><\/pre>\n\n\n\n<p><strong>Examples of source\/target:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Local file: <code>file.txt<\/code> or <code>.\/dir\/file.txt<\/code><\/li>\n\n\n\n<li>Remote file: <code>user@server:\/path\/to\/file.txt<\/code><\/li>\n\n\n\n<li>IPv6 host: <code>user@[2001:db8::1]:\/path<\/code><\/li>\n<\/ul>\n\n\n\n<p>Key rule: A trailing colon indicates a remote host. Without a colon, it\u2019s a local path. For remote directories, add the path after the colon.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"essential-scp-examples-with-clear-use-cases\">Essential SCP Examples (With Clear Use Cases)<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"1-copy-a-file-from-local-to-remote\">1) Copy a file from local to remote<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>scp index.html user@server:\/var\/www\/html\/<\/code><\/pre>\n\n\n\n<p>Use this to upload web assets, configs, or scripts to a server. If the remote path is a directory, SCP places the file inside it.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"2-copy-a-file-from-remote-to-local\">2) Copy a file from remote to local<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>scp user@server:\/etc\/nginx\/nginx.conf .\/<\/code><\/pre>\n\n\n\n<p>Great for pulling logs or configuration backups from a server to your workstation.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"3-copy-an-entire-directory-recursive\">3) Copy an entire directory (recursive)<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>scp -r .\/site\/ user@server:\/var\/www\/html\/<\/code><\/pre>\n\n\n\n<p><code>-r<\/code> copies directories recursively. Add <code>-p<\/code> to preserve timestamps and permissions:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>scp -rp .\/site\/ user@server:\/var\/www\/html\/<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"4-specify-a-non-default-ssh-port\">4) Specify a non default SSH port<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>scp -P 2222 backup.tar.gz user@server:\/backups\/<\/code><\/pre>\n\n\n\n<p>Important: The port flag is uppercase <code>-P<\/code> (lowercase <code>-p<\/code> is \u201cpreserve\u201d).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"5-use-an-ssh-private-key-pem-ed25519-rsa\">5) Use an SSH private key (PEM\/ED25519\/RSA)<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>scp -i ~\/.ssh\/id_ed25519 app.war ubuntu@server:\/opt\/apps\/<\/code><\/pre>\n\n\n\n<p>You can also pass SSH config options generically:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>scp -o IdentityFile=~\/.ssh\/key.pem -o IdentitiesOnly=yes file ubuntu@server:\/home\/ubuntu\/<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"6-handle-spaces-hidden-files-and-wildcards\">6) Handle spaces, hidden files, and wildcards<\/h3>\n\n\n\n<p>Quote paths with spaces, and quote remote wildcards so they expand on the remote host:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Local file with spaces\nscp \"My Report.pdf\" user@server:\/home\/user\/docs\/\n\n# Remote wildcard: quote to prevent local shell expansion\nscp 'user@server:\/var\/log\/*.log' .\/logs\/\n\n# Copy hidden files\nscp -r .\/app\/.env user@server:\/var\/www\/app\/<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"7-remote-to-remote-copies-via-your-local-machine\">7) Remote to remote copies (via your local machine)<\/h3>\n\n\n\n<p>Use <code>-3<\/code> to copy between two remote servers, routing through your client (data passes through your machine):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>scp -3 admin@hostA:\/var\/backups\/db.sql admin@hostB:\/var\/restore\/<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"8-use-a-jump-host-bastion\">8) Use a jump host (bastion)<\/h3>\n\n\n\n<p>For private servers behind a bastion, <code>-J<\/code> simplifies routing:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>scp -J bastion@public-gw ubuntu@internal-app:\/etc\/hosts .\/<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"must-know-scp-options-and-what-they-do\">Must Know SCP Options and What They Do<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>-r<\/code>: Recursive copy (directories)<\/li>\n\n\n\n<li><code>-p<\/code>: Preserve timestamps, modes<\/li>\n\n\n\n<li><code>-P &lt;port&gt;<\/code>: SSH port (uppercase P)<\/li>\n\n\n\n<li><code>-i &lt;key&gt;<\/code>: Use identity file (private key)<\/li>\n\n\n\n<li><code>-o &lt;ssh_option&gt;<\/code>: Pass SSH options (e.g., <code>-o StrictHostKeyChecking=yes<\/code>)<\/li>\n\n\n\n<li><code>-C<\/code>: Compression (helpful for text, configs, logs)<\/li>\n\n\n\n<li><code>-l &lt;limit&gt;<\/code>: Limit bandwidth in Kbit\/s (e.g., <code>-l 4000<\/code>)<\/li>\n\n\n\n<li><code>-J &lt;jump&gt;<\/code>: Jump host (bastion)<\/li>\n\n\n\n<li><code>-3<\/code>: Remote-to-remote via local<\/li>\n\n\n\n<li><code>-4<\/code> \/ <code>-6<\/code>: Force IPv4\/IPv6<\/li>\n\n\n\n<li><code>-F &lt;file&gt;<\/code>: Use alternate SSH config file<\/li>\n\n\n\n<li><code>-q<\/code> \/ <code>-v<\/code>: Quiet \/ Verbose (add more v\u2019s for debug)<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"ssh-keys-and-config-for-frictionless-scp\">SSH Keys and Config for Frictionless SCP<\/h2>\n\n\n\n<p>Password prompts slow you down and aren\u2019t ideal for automation. Use <a href=\"https:\/\/www.youstable.com\/blog\/how-to-add-ssh-keys-to-github-account\/\">SSH keys<\/a> and an SSH config file for a smooth experience.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"generate-a-key-and-authorize-it\">Generate a key and authorize it<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># Create an ED25519 key (fast and secure)\nssh-keygen -t ed25519 -C \"you@machine\"\n\n# Copy the public key to the server\nssh-copy-id -i ~\/.ssh\/id_ed25519.pub user@server<\/code><\/pre>\n\n\n\n<p>If <code>ssh-copy-id<\/code> isn\u2019t available, paste the public key into <code>~\/.ssh\/authorized_keys<\/code> on the server and set permissions:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>chmod 700 ~\/.ssh\nchmod 600 ~\/.ssh\/authorized_keys<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"simplify-with-ssh-config\">Simplify with ~\/.ssh\/config<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>Host web-prod\n  HostName 203.0.113.10\n  User ubuntu\n  IdentityFile ~\/.ssh\/id_ed25519\n  Port 22\n  Compression yes\n\n# Then simply run:\nscp .\/build.zip web-prod:\/var\/www\/html\/<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"security-best-practices-for-scp\">Security Best Practices for SCP<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Verify host keys on first connect; do not disable checks with <code>-o StrictHostKeyChecking=no<\/code> except in controlled CI.<\/li>\n\n\n\n<li>Prefer SSH keys over passwords; restrict keys with proper permissions and passphrases.<\/li>\n\n\n\n<li>Use least privilege accounts; avoid using root unless necessary.<\/li>\n\n\n\n<li>Harden SSH: use a non default port if appropriate, disable password auth, enforce strong ciphers and MACs.<\/li>\n\n\n\n<li>Audit transfers via logs (<code>\/var\/log\/auth.log<\/code> or system journal) in regulated environments.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"troubleshooting-scp-quick-fixes\">Troubleshooting SCP (Quick Fixes)<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"permission-denied-publickeypassword\">Permission denied (publickey,password)<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Ensure you\u2019re using the correct user and key (<code>-i<\/code> or SSH config).<\/li>\n\n\n\n<li>Check server side permissions on <code>~\/.ssh<\/code> (700) and <code>authorized_keys<\/code> (600).<\/li>\n\n\n\n<li>Run <code>scp -v<\/code> to see which key is attempted.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"no-such-file-or-directory\">No such file or directory<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Quote remote paths\/wildcards so your local shell doesn\u2019t expand them.<\/li>\n\n\n\n<li>Confirm the directory exists on the target; create with ssh user@server <a href=\"https:\/\/www.youstable.com\/blog\/mkdir-command-in-linux\">&#8220;mkdir<\/a> -p \/path&#8221; before copying.<\/li>\n\n\n\n<li>Use absolute paths to avoid confusion with remote shell\u2019s working directory.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"connection-timed-out-or-refused\">Connection timed out or refused<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Check firewall\/security groups for TCP 22 (or your custom port).<\/li>\n\n\n\n<li>Verify DNS or use the server\u2019s IP; force IPv4 with <code>-4<\/code> if needed.<\/li>\n\n\n\n<li>Use <code>scp -v<\/code> to diagnose port\/host reachability and auth negotiation.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"scp-command-not-found-remote\">scp: command not found (remote)<\/h3>\n\n\n\n<p>On minimal images, ensure OpenSSH utilities are installed and the SFTP subsystem is enabled. Current OpenSSH scp uses SFTP by default, which must be available on the server.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"performance-and-reliability-tips\">Performance and Reliability Tips<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use compression for text heavy transfers: <code>scp -C logs.tar.gz user@server:\/tmp\/<\/code><\/li>\n\n\n\n<li>Choose fast ciphers if you have CPU headroom (varies by OpenSSH version), e.g., <code>-c aes128-gcm@openssh.com<\/code> or <code>-c chacha20-poly1305@openssh.com<\/code>.<\/li>\n\n\n\n<li>Throttle to protect bandwidth: <code>scp -l 8000 big.img user@server:\/data\/<\/code> (8000 Kbit\/s \u2248 1 MB\/s).<\/li>\n\n\n\n<li>Parallelization: scp itself isn\u2019t parallel or resumable. For large trees or flaky links, prefer <code>rsync -azP<\/code> or SFTP with resume.<\/li>\n\n\n\n<li>Avoid unnecessary encryption overhead on LAN by using faster ciphers; on WAN, compression can help.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"scp-vs-rsync-vs-sftp-which-should-you-use\">SCP vs rsync vs SFTP: Which Should You Use?<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use SCP when you need a quick, one off, encrypted copy with simple syntax.<\/li>\n\n\n\n<li>Use rsync for incremental syncs, resume support, checksums, and robust directory mirroring.<\/li>\n\n\n\n<li>Use SFTP for interactive sessions, resumable uploads\/downloads, and granular file operations.<\/li>\n\n\n\n<li>Use rclone for object storage (S3, GCS), cloud native workflows, and cross provider sync.<\/li>\n<\/ul>\n\n\n\n<p>Note: Despite headlines about \u201cSCP deprecation,\u201d modern OpenSSH keeps the scp command but implements transfers over SFTP by default for safer behavior. You can keep using scp confidently on up to date systems.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"cloud-examples-aws-gcp-azure\">Cloud Examples: AWS, GCP, Azure<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>AWS EC2 (Ubuntu): <code>scp -i ~\/keys\/aws.pem app.tar.gz ubuntu@&lt;public-ip&gt;:\/opt\/<\/code><\/li>\n\n\n\n<li>AWS EC2 (Amazon Linux): <code>scp -i ~\/keys\/aws.pem site.zip ec2-user@&lt;public-ip&gt;:\/var\/www\/html\/<\/code><\/li>\n\n\n\n<li>GCP Compute Engine: <code>scp -i ~\/.ssh\/gcp ed@&lt;external-ip&gt;:\/var\/log\/syslog .\/<\/code> (ensure firewall allows SSH)<\/li>\n\n\n\n<li>Azure VM: <code>scp -P 22 -i ~\/.ssh\/azure key.pub azureuser@&lt;public-ip&gt;:~\/.ssh\/<\/code><\/li>\n\n\n\n<li>Behind a bastion: <code>scp -J user@bastion targetuser@10.0.0.10:\/etc\/nginx\/nginx.conf .\/<\/code><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"automate-scp-in-scripts-and-cron\">Automate SCP in Scripts and Cron<\/h2>\n\n\n\n<p>For nightly backups or CI deploys, pair keys with a locked down user and explicit SSH options. Here\u2019s a reliable pattern:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/usr\/bin\/env bash\nset -euo pipefail\n\nHOST=\"web-prod\"\nSRC_DIR=\"\/var\/backups\"\nDST_PATH=\"\/backups\/$(date +%F)\"\nLOG=\"\/var\/log\/backup_scp.log\"\n\nmkdir -p \"$SRC_DIR\"\ntar -czf \"$SRC_DIR\/site-$(date +%F).tar.gz\" \/var\/www\/html\/\n\n# Copy with compression, bandwidth limit, and strict host key checking\nscp -C -l 8000 -o BatchMode=yes -o StrictHostKeyChecking=yes \\\n  \"$SRC_DIR\/site-$(date +%F).tar.gz\" \"${HOST}:${DST_PATH}\/\" &gt;&gt; \"$LOG\" 2&gt;&amp;1\n\necho \"Backup completed at $(date)\" &gt;&gt; \"$LOG\"<\/code><\/pre>\n\n\n\n<p>Schedule with cron (<code>crontab -e<\/code>). For high change datasets or large directories, switch to rsync to avoid re-uploading unchanged files.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"real-world-tips-from-hosting-operations\">Real World Tips From Hosting Operations<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Quote remote globs: <code>scp 'user@host:\/var\/log\/app\/*.log' .\/<\/code> prevents local shell expansion errors.<\/li>\n\n\n\n<li>Use host aliases in <code>~\/.ssh\/config<\/code> to standardize ports, keys, and jump hosts across your team.<\/li>\n\n\n\n<li>Deploy packs as archives (<code>tar.gz<\/code>) rather than thousands of small files; SCP handles fewer, larger files more efficiently.<\/li>\n\n\n\n<li>Throttle during business hours with <code>-l<\/code> to protect customer traffic; remove the limit off hours.<\/li>\n\n\n\n<li>In CI\/CD, force strict host key checks and pin host keys to prevent MITM risks.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"faqs\">FAQs<\/h2>\n\n\n<div id=\"rank-math-faq\" class=\"rank-math-block\">\n<div class=\"rank-math-list \">\n<div id=\"faq-question-1765513136169\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \" class=\"rank-math-question \" id=\"is-scp-deprecated-should-i-still-use-it\">Is SCP deprecated? Should I still use it?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>The scp command still exists and is maintained. Newer OpenSSH versions implement scp using SFTP by default for safer behavior. For quick, secure copies, SCP is fine; for resumable, incremental transfers, use rsync or SFTP.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1765513153850\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \" class=\"rank-math-question \" id=\"how-do-i-specify-a-port-with-scp\">How do I specify a port with SCP?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>Use uppercase <code>-P<\/code>, for example: <code>scp -P 2222 file user@server:\/path\/<\/code>. Alternatively, set the Port in <code>~\/.ssh\/config<\/code> for a host alias.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1765513162252\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \" class=\"rank-math-question \" id=\"how-do-i-copy-an-entire-folder-with-scp\">How do I copy an entire folder with SCP?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>Add <code>-r<\/code> for recursion and <code>-p<\/code> to preserve metadata: <code>scp -rp .\/folder user@server:\/path\/<\/code>. Consider rsync for large trees and repeated syncs.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1765513220884\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \" class=\"rank-math-question \" id=\"how-do-i-use-a-pem-private-key-with-scp\">How do I use a PEM\/private key with SCP?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>Use <code>-i<\/code>: <code>scp -i ~\/keys\/key.pem file ubuntu@&lt;ip&gt;:\/path\/<\/code>. You can also define <code>IdentityFile<\/code> in <code>~\/.ssh\/config<\/code> for a cleaner command and set <code>IdentitiesOnly yes<\/code>.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1765513232167\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \" class=\"rank-math-question \" id=\"can-scp-resume-interrupted-transfers\">Can SCP resume interrupted transfers?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>No. SCP lacks native resume. Use <code>rsync -P<\/code> or SFTP\u2019s <code>reget<\/code>\/<code>reput<\/code> for resumable transfers, especially over unstable links or for large files.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1765513239138\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \" class=\"rank-math-question \" id=\"why-does-scp-keep-asking-for-my-password\">Why does SCP keep asking for my password?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>Likely missing or mismatched SSH keys, wrong user, or server side perms on <code>~\/.ssh<\/code>\/<code>authorized_keys<\/code>. Ensure correct <code>-i<\/code> file, set <code>chmod 700 ~\/.ssh<\/code> and <code>chmod 600 ~\/.ssh\/authorized_keys<\/code>, and verify your SSH config.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1765513246324\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \" class=\"rank-math-question \" id=\"how-do-i-verify-that-my-scp-transfer-succeeded\">How do I verify that my SCP transfer succeeded?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>SCP exits with 0 on success. For critical workflows, compare checksums: <code>sha256sum file<\/code> locally and remotely after transfer. For large directories, prefer rsync with checksums.<\/p>\n\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"conclusion\">Conclusion<\/h2>\n\n\n\n<p>The SCP command in Linux offers a fast, secure, and straightforward way to move files across servers using SSH. Master the core options (<code>-r<\/code>, <code>-p<\/code>, <code>-P<\/code>, <code>-i<\/code>, <code>-C<\/code>, <code>-J<\/code>, <code>-l<\/code>), adopt SSH keys and configs, and lean on rsync\/SFTP when you need resume and synchronization. With the right practices, and a reliable hosting partner like YouStable, you\u2019ll transfer data safely and efficiently at any scale.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The SCP command in Linux securely copies files and directories between local and remote systems over SSH. It encrypts data [&hellip;]<\/p>\n","protected":false},"author":13,"featured_media":15460,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[350,1195],"tags":[],"class_list":["post-12316","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-knowledgebase","category-blogging"],"acf":[],"featured_image_src":"https:\/\/www.youstable.com\/blog\/wp-content\/uploads\/2025\/12\/SCP-command-in-linux.jpg","author_info":{"display_name":"Prahlad Prajapati","author_link":"https:\/\/www.youstable.com\/blog\/author\/prahladblog"},"_links":{"self":[{"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/posts\/12316","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/comments?post=12316"}],"version-history":[{"count":7,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/posts\/12316\/revisions"}],"predecessor-version":[{"id":19203,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/posts\/12316\/revisions\/19203"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/media\/15460"}],"wp:attachment":[{"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/media?parent=12316"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/categories?post=12316"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/tags?post=12316"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}