01
Read the error together with the command
Identify which argument is the source and which is the destination. Confirm that the local file exists and that the remote user, host, and port match the successful login. In scp, a custom port uses uppercase -P.
OpenSSH 9.0 and later use SFTP by default for scp. Shell-era quoting or assumptions about remote wildcard expansion may no longer match the transfer protocol. Inspect verbose output rather than immediately forcing legacy mode.
ls -l ./report.txt
scp -v -P 2222 ./report.txt developer@server.example.com:/home/developer/transfers/report.txt02
Inspect the destination in its actual context
For an ordinary shell account, check the parent directory through SSH. For an SFTP-only or chrooted account, use SFTP’s pwd and ls to inspect the paths that account can see. A path visible in an administrator shell may not exist in the restricted SFTP view.
In the lab, uploading to a nonexistent parent directory failed even though authentication succeeded. The missing-parent error did not require replacing the key, changing the SSH port, or broadening filesystem permissions.
sftp -P 2222 developer@server.example.com
# At the SFTP prompt, inspect the remote view:
pwd
ls -l /home/developer03
Create or select the intended directory
For the unrestricted lab account we created a dedicated transfers directory owned by that user, then retried the same upload there. On a real system, confirm that creating the directory is part of the intended workflow and that the user is allowed to write it.
Do not solve a missing directory with recursive chmod 777 or by running every transfer as root. A managed drop zone or chroot layout may require the administrator to provision the destination instead of the uploader.
# Ordinary shell account; adjust paths to the actual server layout.
ssh -p 2222 developer@server.example.com \
'mkdir -p /home/developer/transfers'
scp -P 2222 ./report.txt \
developer@server.example.com:/home/developer/transfers/report.txt04
Verify the file rather than just the progress display
Our corrected upload succeeded and produced the same SHA-256 checksum on the client and server. This established that the intended test bytes reached the chosen path. The checksum comparison was a separate step from successful SSH authentication.
On macOS, shasum -a 256 is commonly available; on Linux, sha256sum is common. Compare the digest field rather than expecting path names in the two outputs to match. For an SFTP-only service, use its supported verification workflow or retrieve the file for comparison.
# macOS client and Linux remote server example:
shasum -a 256 ./report.txt
ssh -p 2222 developer@server.example.com \
'sha256sum /home/developer/transfers/report.txt'05
Separate path repairs from protocol compatibility
A server without an SFTP subsystem can fail differently from one with a missing directory. Confirm which failure you have before considering legacy scp compatibility. Switching protocols cannot create an absent parent directory.
Use an explicit, known path during diagnosis. Once that works, introduce spaces, shell characters, or application-specific directory rules one at a time. Preserve the successful minimal command so the next failure has a concrete comparison.
Know the limits
Reproduced with OpenSSH 9.2p1 scp using SFTP and an ordinary Linux account. Chrooted SFTP users may see a different filesystem root from a shell account. OpenSSH 9.0 changed scp’s default transfer protocol; older clients can behave differently.
Sources & further reading
A technical publication by CoreTrailKit.
Browse all articles