bash-tutorial/tutorial/copy_server.org

1.6 KiB

Transfering files

Let's say you want to transfer files, images or directories between a local machine and a server. What could be a good option?

There are multiple free software options to transfer file between machines:

  • rsync
  • sftp (secury file transfer protocol)
  • scp (secure copy protocol)

rsync

For example: transfering all the .jpg files in the directory to a server:

  rsync -a -P -e "ssh -p 2222" ./*.jpg root@186.76.90.145:/root/img/

scp

Using sftp to copy files

sftp can be used to transfer files from a local machine to a server. The protocol allows to access the server, visualize, manipulate and transfer files from and to a server. You need to configure ssh access to the server from your local machine.

A server can be accessed from a local machine following this logic:

  sftp -P 2222 root@186.76.90.145

The command sftp followed by the port and user@ip_address.

After accessing the server, files can be download from the server:

 sftp> get file_in_server

You can also transfer files to the server:

 sftp> put file_in_local_machine

To exit from sftp use:

 sftp> put file_in_local_machine

There are additional options to use sftp. Check the manual to know more about:

  info sftp

References