SSH is an important tool to remote connect to Linux machines and control them remotely. Essentially the terminal is forwarded to the other machine, which is incredibly handy.
ssh $USER@$HOST
eg:
ssh johann@johanns-server
install your public key on a remote host:
ssh-copy-id -i ~/.ssh/id_ed25519.pub $USER@$HOST
then connect with:
ssh -i ~/.ssh/id_ed25519 $USER@$HOST
Create the addressbook directory in home:
mkdir ~/ssh-connections
Create or edit a connection entry
nano ~/ssh-connections/myconnection.sh
chmod +x ~/ssh-connections/myconnection.sh
#!/bin/bash
# Define the SSH connection details
USER="user"
HOST="192.168.1.1"
# Connect to the server
ssh -i ~/.ssh/id_ed25519 $USER@$HOST
connect
ls ~/ssh-connections
~/ssh-connections/myconnection.sh
rsync (Remote Synchronization) is a command-line utility for efficiently copying and synchronizing files between local and remote systems. It is particularly useful for backups, mirroring, and minimizing data transfer by copying only file differences (incremental updates).
Note: Rsync must be installed locally and on a potential remote host
sudo apt install rsync # Debian/Ubuntu
sudo yum install rsync # CentOS/Red Hat
sudo dnf install rsync # Fedora
rsync [options] source destination
/path/to/fileuser@host:/path/to/file: character is used to specify remote paths.rsync -av --progress /source/path/ /destination/path/
-a: Archive mode (preserves file permissions, timestamps, etc.).-v: Verbose output.rsync -avz --progress -e ssh /local/path/ user@remote:/remote/path/
This copies all files and subdirectories from the local path to the remote system.
rsync -avz --delete -e ssh /source/path/ /destination/path/
--delete: Removes files from the destination that are no longer in the source.--exclude="pattern": Excludes files or directories matching a pattern.rsync -avz --delete -e ssh --exclude="Save" /source/path/ /destination/path/
Use Dry-Run Mode:
Add --dry-run to preview actions without making changes:
rsync -av --dry-run /source/path/ /destination/path/
Secure Transfers:
Always use SSH (-e ssh) when transferring over the network.
Avoid Trailing Slashes:
/source/path/: Syncs contents of the directory./source/path: Syncs the directory itself.-z for compression and optimize SSH settings.