Transferring Files with scp

Learn how to copy files from and to remote machines using the scp command.

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:

  1. Upon the first prompt, enter 123456 as the password.
  2. Type su sshuser.
  3. Type scp temp@ /home/sshuser.
  4. Upon the next prompt, type yes and press “Enter.”
  5. Enter the password set earlier and press “Enter.”
  6. To verify that the files have been copied, type ls /home/sshuser.

Get hands-on with 1200+ tech skills courses.