Difference between revisions of "SSH"
(Created page with "== SSH (Secure Shell) == '''SSH''' (''Secure Shell'') is a cryptographic network protocol that allows secure communication between two networked devices. It is most commonly...") |
|||
Line 29: | Line 29: | ||
=== Basic SSH Command === | === Basic SSH Command === | ||
− | + | ||
− | ssh username@hostname | + | ssh username@hostname |
− | + | ||
Example: | Example: | ||
− | + | ||
− | ssh user@192.168.1.100 | + | ssh user@192.168.1.100 |
− | + | ||
This connects to the host at IP `192.168.1.100` using the specified username. | This connects to the host at IP `192.168.1.100` using the specified username. | ||
Line 47: | Line 47: | ||
1. Generate keys: | 1. Generate keys: | ||
− | + | ||
− | ssh-keygen -t rsa -b 4096 | + | ssh-keygen -t rsa -b 4096 |
− | + | ||
2. Copy the public key to the remote server: | 2. Copy the public key to the remote server: | ||
− | + | ||
− | ssh-copy-id user@hostname | + | ssh-copy-id user@hostname |
− | + | ||
3. Now, you can connect without entering a password. | 3. Now, you can connect without entering a password. | ||
Line 63: | Line 63: | ||
* **SCP** – Secure copy files: | * **SCP** – Secure copy files: | ||
− | + | ||
− | scp file.txt user@hostname:/remote/path/ | + | scp file.txt user@hostname:/remote/path/ |
− | + | ||
* **SFTP** – Interactive secure file transfer: | * **SFTP** – Interactive secure file transfer: | ||
− | + | ||
− | sftp user@hostname | + | sftp user@hostname |
− | + | ||
=== SSH Configuration File === | === SSH Configuration File === | ||
Line 77: | Line 77: | ||
User-specific SSH options can be set in: | User-specific SSH options can be set in: | ||
− | + | ||
− | ~/.ssh/config | + | ~/.ssh/config |
− | + | ||
Example: | Example: | ||
− | + | ||
Host seedbox | Host seedbox | ||
HostName your.seedbox.com | HostName your.seedbox.com | ||
User yourusername | User yourusername | ||
Port 22 | Port 22 | ||
− | + | ||
Now you can connect using: | Now you can connect using: | ||
− | + | ||
− | ssh seedbox | + | ssh seedbox |
− | + | ||
=== Security Tips === | === Security Tips === | ||
Line 113: | Line 113: | ||
* [[SFTP]] | * [[SFTP]] | ||
− | |||
* [[OpenSSH]] | * [[OpenSSH]] | ||
− | |||
− | |||
− | |||
− |
Revision as of 14:02, 19 May 2025
Contents
SSH (Secure Shell)
SSH (Secure Shell) is a cryptographic network protocol that allows secure communication between two networked devices. It is most commonly used to log into remote systems and execute commands over an encrypted connection. SSH is a foundational tool in system administration, server management, and remote file transfers.
SSH replaces older, insecure protocols like Telnet and rlogin by encrypting all data exchanged between the client and server, including passwords, commands, and file transfers.
Key Features
- **Encrypted communication** – Prevents eavesdropping and man-in-the-middle attacks
- **Remote shell access** – Run commands on remote systems
- **Port forwarding/tunneling** – Securely forward ports between systems
- **Public key authentication** – Log in without passwords using cryptographic keys
- **File transfer support** – Via built-in tools like `scp` and `sftp`
Default Port
- SSH operates on **TCP port 22** by default.
Common Usage
SSH is used for:
- Managing remote Linux or Unix-based servers
- Accessing seedboxes, cloud instances, and VPS
- Securely copying files between machines
- Tunneling traffic for applications or databases
- Automation with shell scripts or cron jobs
Basic SSH Command
ssh username@hostname
Example:
ssh user@192.168.1.100
This connects to the host at IP `192.168.1.100` using the specified username.
SSH Key Authentication
SSH supports login via a key pair (public/private):
1. Generate keys:
ssh-keygen -t rsa -b 4096
2. Copy the public key to the remote server:
ssh-copy-id user@hostname
3. Now, you can connect without entering a password.
File Transfer with SSH
- **SCP** – Secure copy files:
scp file.txt user@hostname:/remote/path/
- **SFTP** – Interactive secure file transfer:
sftp user@hostname
SSH Configuration File
User-specific SSH options can be set in:
~/.ssh/config
Example:
Host seedbox
HostName your.seedbox.com User yourusername Port 22
Now you can connect using:
ssh seedbox
Security Tips
- Use **SSH keys** instead of passwords
- Disable root login (`PermitRootLogin no`) in the SSH configuration
- Change the default port from 22 to another port
- Use a firewall (e.g., ufw or iptables)
- Monitor for brute-force attempts with tools like fail2ban
Related Tools
- OpenSSH – The most common SSH implementation for Unix-like systems
- PuTTY – A popular SSH client for Windows
- WinSCP – GUI-based file transfer over SSH for Windows