rsync is a utility for transferring and synchronising files between a computer and a storage drive and across networked computers by delta-transfer algorithm (using modification time and size by default, or checksums with the --checksum option). It is commonly found on Unix-like operating systems and is under the GPL-3.0-or-later license.
rsync -avz source_dir/your_file.txt user@server_ip:target_dir/
-a: to transfer the file in archive mode, which preserves file permissions, ownership, timestamps, and symbolic links.
-v: to enables verbose output, providing more details about the transfer process.
-z: to compress the data during transfer, saving bandwidth and potentially speeding things up.
-h : converts the bytes to a more understandable unit based on the size. (1048576 bytes → 1.0M)
-p : preserve permissions from source to destination
--chmod : for more granular control over permissions
# Set all files to 644
rsync -avzh --chmod=F644 /path/to/local/files/ user@server_ip:/dest
# Set directories to 755 and files to 644:
rsync -avzh --chmod=D0755,F644 /path/to/local/files/ user@server_ip:/dest
rsync works with SSHUnlike ssh accesses config file to find user private key for signing challenge, rsync uses a different way.
rsync command with the source, destination (including username and server address), and options.rsync uses SSH to establish a secure connection to the remote server.rsync is not directly involved in this process. Your SSH client software (like OpenSSH) handles the handshake.~/.ssh/authorized_keys file on the server, but the location can vary depending on server configuration.rsync then uses the established secure SSH connection to transfer data efficiently.