Skip to content

Q&A · Answered

How to copy files between servers using SCP

asked 9 months, 1 week ago 1749 views 1 answer
43

I need to transfer files from one server to another. How do I use scp?

1 Answer

One accepted
20

Accepted answer

Not confirmed since it was written, 9 months, 1 week ago
# Copy file to remote server
scp /local/file.txt user@remote:/path/

# Copy from remote to local
scp user@remote:/path/file.txt /local/

# Copy entire directory
scp -r /local/dir user@remote:/path/

# With specific port
scp -P 2222 file.txt user@remote:/path/

Your answer

Say what you tried, not only what worked — the next person needs the reasoning. Code goes in a fenced block.

Shown beside your answer and never checked, so it cannot be a name someone already has here.

No account needed to answer. Sign in instead and it carries your name and earns reputation.