Pcornel
Browse topics
Options
Recent
Favorites
Linux · Technical reference

SCP

Direct answer

scp copies files over SSH (scp file user@host:/path). Newer OpenSSH versions use the SFTP protocol underneath.

When to use this

Use it for quick file copies between hosts, or when a copy fails.

First 30 seconds

1. ssh user@host true — plain SSH works?

2. Copy with scp -v to see errors.

3. Breaks with protocol errors → remove output from ~/.bashrc on the server.

4. Permissions on the target directory?

5. Large/repeated → rsync -avP -e ssh.

Operational verification

ssh connection → authenticated → file stream over the SSH channel → written on the target

Evidence · next step

For SSH → SCP, continue with the first unproven Topic check: Record OpenSSH version, SCP mode/options, exact source/destination and transfer direction. If that boundary is healthy, advance to the adjacent check: Verify SSH auth first, then local and remote path existence/permissions/space independently. Preserve the same host/time/identity scope and rerun the original workload before accepting recovery.

Continue only after interpreting the current observation.
Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
linux
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

Platformlinux
Scope / prerequisiteUse it for quick file copies between hosts, or when a copy fails.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

5 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 Operational evidence path Verify boundary

scp invocation/mode → SSH transport/auth → source path/read → transfer subsystem/protocol → destination path/write → close/metadata → file verification → consumer workload

Healthy evidence: SSH transport authenticates, source and destination paths resolve as intended, transfer completes without errors and destination content/metadata meet explicit acceptance checks.

Step 2 Verification and output interpretation Verify boundary

For tunneling/SFTP/SCP, verify the requested channel/subsystem after authentication rather than assuming login success shows every SSH feature.

Existing fast checks for this Topic. - Record OpenSSH version, SCP mode/options, exact source/destination and transfer direction.

  • Verify SSH auth first, then local and remote path existence/permissions/space independently.
  • Capture transfer exit status and server-side errors for the same attempt.
  • Validate destination file size/hash/ownership/mode according to the actual acceptance requirement.

Verification chain. scp invocation/mode → SSH transport/auth → source path/read → transfer subsystem/protocol → destination path/write → close/metadata → file verification → consumer workload

Step 3 Commands Verify boundary
scp file user@host:/tmp/
scp -r dir user@host:/srv/
Step 4 Failure modes and next checks Narrow the fault

Suspicious evidence: interactive SSH works but path permissions fail, version-dependent SCP/SFTP mode changes behavior, quoting expands unexpectedly or progress completion is accepted without file verification.

Step 5 Common mistakes Narrow the fault
  • Expecting scp to resume or preserve ACLs (use rsync).
Evidence references

Evidence · 1 on this Topic

Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.

observation · 1
Key points

Uses the same authentication as ssh. Output from shell startup files (echo in ~/.bashrc) can break transfers. For large or repeated copies use rsync over SSH, which can resume and copy only changes.

Key checks
  • ssh -v user@host — client-side connection and authentication steps
  • journalctl -u ssh -u sshd -e — server log
  • sshd -T — effective server settings
  • ss -ltnp | grep :22 — sshd listening
ReferenceWhat it is1 section · depth on demand

Core model

Pin client version/mode, source and destination syntax, remote user/path and direction. Separate SSH transport/authentication from local/remote path expansion and filesystem permissions, then verify resulting file identity, size/hash/metadata as required rather than relying on progress output alone.

ReferenceImportant terms & boundaries5 sections · depth on demand

What this shows and what it does not

SCP command success shows a bounded transfer result; it does not automatically show cryptographic content identity, desired ownership/mode or downstream consumer usability.

In depth

scp: copying files over SSH

scp copies files between hosts over an SSH connection. The scp(1) manual page notes an important change: since OpenSSH 9.0, scp uses the SFTP protocol for transfers by default. -O switches back to the legacy SCP protocol, which may be needed for servers without SFTP or for older wildcard and ~ behaviour.

Options (manual)

OptionPurpose
-rCopy directories recursively (follows symbolic links)
-pPreserve modification and access times and mode bits
-P <port>Port (capital P, because -p is taken)
-i <key>Identity file
-J <jump>Jump hosts
-l <kbit/s>Bandwidth limit
-CCompression
-3Copy between two remote hosts through the local host (the default)
-OLegacy SCP protocol

Remote to remote

By default, a copy between two remote hosts goes through the local machine. With -R, the copy runs directly between the two remote hosts, so the first host must be able to authenticate to the second without a password.

Quoting and wildcards

With the legacy protocol, the remote shell expands wildcards, so special characters need careful quoting. scp also rejects received file names that don't match what was requested, unless -T is used. That check exists because a malicious server could otherwise send unexpected files.

admin$ scp -p backup-2026-11-28.tar.gz srv1:/srv/backup/
admin$ scp -r -J bastion srv-db1:/var/log/postgresql ./db1-logs/
admin$ scp -P 2222 -i ~/.ssh/id_ed25519_work config.yml admin@10.30.0.11:/etc/app/
admin$ scp -l 20000 large.iso srv1:/srv/iso/
admin$ scp srv1:'/var/log/nginx/access.log.*.gz' ./
admin$ scp -O oldappliance:/cfg/running.cfg ./

scp, sftp or rsync

NeedTool
A quick one-off copyscp
Interactive browsing, resuming, batch scriptssftp
Large trees, repeated syncs, only changed filesrsync -e ssh

scp has no resume and no delta transfer. For anything you'll repeat or that is large, rsync over SSH is usually the better tool.

Documented example, not captured output.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

How it works at runtime

Topic-specific state model. SCP is an SSH-based file-copy workflow whose transport may use modern SFTP semantics depending on OpenSSH version/options; transfer success depends on SSH authentication plus source/destination path interpretation, permissions, space and write/read completion.

Interpretation rule. - SSH login works ≠ SCP path/permission semantics work.

  • Transfer command exits successfully ≠ file content/metadata matches acceptance criteria.
  • Remote path string ≠ same expansion rules across shells/protocol modes.
  • SCP name ≠ legacy SCP wire protocol is necessarily being used by modern OpenSSH.

Quick reference

SCP copies files over SSH. Since OpenSSH 9.0, scp uses the SFTP protocol by default (the legacy SCP protocol had design flaws).

scp -p report.csv alice@web01:/tmp/
scp -r -J bastion ./site ops@10.0.30.15:/srv/www/
scp -O old-server:/file .        # force legacy protocol for very old servers

For large or repeated transfers prefer rsync -aP -e ssh (resumable, only differences).

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

Limits and how it fails

Primary failure point. SCP command success shows a bounded transfer result; it does not automatically show cryptographic content identity, desired ownership/mode or downstream consumer usability.

ReferenceConfiguration & state1 section · depth on demand

Configuration, persistence and lifecycle

Distribution/platform context. SCP owns SSH file-copy semantics. SFTP owns subsystem-oriented transfer behavior; Filesystem and Users/Permissions own local path, ownership and permission semantics.

Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor doclinux current

Authoritative/upstream documentation reviewed for bounded claims in SSH → SCP. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://www.openssh.com/manual.html · confidence 94%
Technical changelog & impact

What changed and what may be affected

Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.

Related reference impactReview these references after material technical changes when their shared boundary is affected.
Terminology layer

Terms & aliases

Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.

Aliases that resolve here
scpsecure copyscp linuxscp over ssh
Embedded reference data

Quick lookup tables

SCP operational reference

Topic-specific lookup boundaries, proof limits and next-step Evidence for SCP.

Lookup boundaryTopic-specific referenceOperational use
Scope / effective stateSCP is an SSH-based file-copy workflow whose transport may use modern SFTP semantics depending on OpenSSH version/options; transfer success depends on SSH authentication plus source/destination path interpretation, permissions, space and write/read completion.Establish exactly what this Topic owns before crossing into another subsystem.
Fast verificationPin exact client/server + attempt time → resolve destination/TCP path → inspect effective client config → identify OpenSSH versions → verify KEX + host-key trust → trace offered/accepted authentication → inspect effective sshd policy for user/source → verify session/subsystem/forward → verify remote process/filesystem/service → repeat original workload.Use the shortest evidence path first; a fast check is a boundary test, not blanket proof.
Verification chainscp invocation/mode → SSH transport/auth → source path/read → transfer subsystem/protocol → destination path/write → close/metadata → file verification → consumer workloadTrace requested/configured state through effective state to the observed workload result.
Failure boundarySCP command success proves a bounded transfer result; it does not automatically prove cryptographic content identity, desired ownership/mode or downstream consumer usability.Stop broad troubleshooting at the first boundary that is not supported by evidence.
Positive evidenceCorrelated Linux SSH evidence can establish this proof path: scp invocation/mode → SSH transport/auth → source path/read → transfer subsystem/protocol → destination path/write → close/metadata → file verification → consumer workloadUse this observation only for the specific claim it actually supports.
Evidence limitIt does not independently prove behavior outside the captured transport, trust, authentication, policy, session, filesystem or workload scope. SCP command success proves a bounded transfer result; it does not automatically prove cryptographic content identity, desired ownership/mode or downstream consumer usability.Do not promote a local success signal into end-to-end or adjacent-dependency proof.
Next troubleshooting checkContinue from the first unproven boundary: correlate client and server evidence for the same attempt, inspect effective client/server configuration and identity/trust/authentication state, then test the exact requested session, transfer or forward before changing additional layers.Continue to the next unresolved boundary while preserving the original test condition.

SCP · operational reference

Compact Linux state, persistence, verification and boundary reference for fast lookup.

Reference boundarySCP
Topic pathSSH → SCP
Runtime stateSCP is an SSH-based file-copy workflow whose transport may use modern SFTP semantics depending on OpenSSH version/options; transfer success depends on SSH authentication plus source/destination path interpretation, permissions, space and write/read completion.
Fast checks- Record OpenSSH version, SCP mode/options, exact source/destination and transfer direction. - Verify SSH auth first, then local and remote path existence/permissions/space independently. - Capture transfer exit status and server-side errors for the same attempt. - Validate destination file size/hash/ownership/mode according to the actual acceptance requirement.
Verification chainscp invocation/mode → SSH transport/auth → source path/read → transfer subsystem/protocol → destination path/write → close/metadata → file verification → consumer workload Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return/regression → explicit Evidence boundary. Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return path or regression → explicit Evidence boundary.
Failure boundarySCP command success proves a bounded transfer result; it does not automatically prove cryptographic content identity, desired ownership/mode or downstream consumer usability. Boundary chain: process/context → userspace configuration → kernel subsystem/resource → device/network/filesystem dependency → effective state → original workload.
Persistence ruleProve which configuration source owns the state, then prove that the running consumer loaded or generated the intended state.
Confirmation

Confirm action

Continue?