Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

How to copy files from one machine to another using ssh

I'm using Linux (centos) machine, I already connected to the other system using ssh. Now my question is how can I copy files from one system to another system?

Suppose, in my environment, I have two systems like System A and System B. I'm using System A machine and some others using System B machine.

How can I copy a file from System B to System A? And, copy a file from System A to System B?
by

2 Answers

rahul07
Syntax:

scp <source> <destination>

To copy a file from B to A while logged into B:

scp /path/to/file username@a:/path/to/destination

To copy a file from B to A while logged into A:

scp username@b:/path/to/file /path/to/destination
sandhya6gczb
In case if you need an alternate approach.

Install sshfs. if you use ubuntu/debian:

sudo apt-get install sshfs

or, if you use centos/rhel:

sudo yum install fuse-sshfs

or, in macOS

brew install sshfs

Create an empty dir

mkdir /home/user/testdir

"link" or "mount" the two directories

sshfs user@server.com:/remote/dir /home/user/testdir

"unlink" the dirs

fusermount -u /home/user/testdir

On BSD and macOS, to unmount the filesystem:

umount mountpoint

or

diskutil unmount mountpoint

Login / Signup to Answer the Question.