Transferring Files with scp
Learn how to copy files from and to remote machines using the scp command.
We'll cover the following
The scp
command
We can copy the data.json
file we created previously from the server to the machine using the scp command. We specify the source path first, followed by the destination path. The source is on the remote server, so we specify the username and server address, followed by the path to the file on the server, using a colon to separate the host from the remote path:
$ scp {username}@{ip}:{source} {destination}
Follow these steps:
- Upon the first prompt, enter
123456
as the password. - Type
su sshuser
. - Type
scp temp@127.0.0.1:data.json /home/sshuser
. - Upon the next prompt, type
yes
and press “Enter.” - Enter the password set earlier and press “Enter.”
- To verify that the files have been copied, type
ls /home/sshuser
.
Get hands-on with 1400+ tech skills courses.