-
SSH: Secure remote access to servers. ๐
- Example:
ssh user@hostname
- Example:
-
SCP: Secure file transfer between local and remote systems. ๐
- Example:
scp file.txt user@hostname:/remote/directory
- Example:
-
RSYNC: Sync files and directories securely between systems. ๐๐
- Example:
rsync -avz /local/dir user@hostname:/remote/dir
- Example:
-
SFTP: Interactive file transfer over SSH. ๐
- Example:
sftp user@hostname
- Example:
-
SSH Keys: Manage public/private key pairs for passwordless login. ๐๏ธ
- Example:
ssh -i ~/.ssh/id_rsa user@hostname
- Example:
SSH (Secure Shell) is a cryptographic network protocol used for securely accessing and managing devices or systems over an unsecured network. It allows users to log into remote systems, execute commands, and transfer files securely. It encrypts all communications to prevent unauthorized access and eavesdropping.
ssh 192.168.1.43Explanation:
- Connects to the remote system at IP
192.168.1.43using the default SSH port (22) and username.
ssh root@192.168.1.31ssh root@192.168.1.34Explanation:
- Specifies the username (
root) to log in to the remote systems at192.168.1.31and192.168.1.34.
ssh -l root -p 2222 192.168.1.34ssh -p 2200 user@192.168.1.50Explanation:
- Uses the
-poption to connect to a custom SSH port (2222,2200), and the-loption specifies the username (root,user).
ssh -i id_rsa_centos root@192.168.1.34ssh -i ~/.ssh/id_ecdsa root@192.168.1.34Explanation:
- The
-ioption specifies the private key file (e.g.,id_rsa_centos,id_ecdsa) for passwordless authentication.
ssh -v root@192.168.1.34ssh -vvv -i ~/.ssh/id_rsa root@192.168.1.34Explanation:
- The
-voption enables verbose output for debugging SSH connections. Use-vvvfor even more detailed output.
ssh root@192.168.1.34 -p 22 'id'Explanation:
- Executes a single command (
id) on the remote server without starting an interactive SSH session.
ssh root@192.168.1.34 'uptime'Explanation:
- Executes the
uptimecommand to display how long the remote system has been running.
ssh root@192.168.1.34 -p 22 -i ~/.ssh/id_rsa 'cat /etc/hostname'Explanation:
- Connects using a specific identity file (
-i ~/.ssh/id_rsa) and port (-p 22), then reads the remote/etc/hostnamefile.
ssh -i ~/.ssh/id_rsa root@192.168.1.34 "df -h"Explanation:
- Executes the
df -hcommand to display the disk space usage in a human-readable format (e.g., MB, GB).
ssh -L 8080:localhost:80 root@192.168.1.34Explanation:
- The
-Loption creates a local port forwarding, allowing you to access the remote web server (port80) locally via port8080.
ssh -J root@gateway root@192.168.1.34Explanation:
- Uses the
-Joption to specify a jump host (gateway) to connect to the internal machine (192.168.1.34).
-
Remote Access: SSH securely connects to remote systems.
Example:ssh root@192.168.1.34 -
Custom Ports & Users: You can specify ports and users for flexibility.
Example:ssh -p 2222 root@192.168.1.34 -
Key-Based Authentication: SSH allows passwordless logins using private keys.
Example:ssh -i ~/.ssh/id_rsa root@192.168.1.34 -
Debugging: SSH offers verbose mode for troubleshooting.
Example:ssh -v root@192.168.1.34 -
Remote Command Execution: Run commands on remote systems without logging in interactively.
Example:ssh root@192.168.1.34 'uptime' -
System Info & File Access: SSH checks disk usage, uptime, and reads files remotely.
Example:ssh root@192.168.1.34 'df -h' -
Port Forwarding: Access remote services via local ports.
Example:ssh -L 8080:localhost:80 root@192.168.1.34 -
Jump Host: SSH connects to an internal machine through an intermediary.
Example:ssh -J root@gateway root@192.168.1.34