ssh (Secure Shell)
ssh is a protocol for secure remote login and other secure network services over an insecure network. It provides a secure, encrypted tunnel for your data, replacing older, insecure methods like Telnet or FTP.
1. Basic Usage
ssh [username]@[remote_host]
2. Key Options & Utilities
| Category | Option/Tool | Description |
|---|---|---|
| Option | -p [port] |
Connects to a specific port instead of the default 22. |
| Option | -i [identity_file] |
Selects a file from which the identity (private key) is read. |
| Tool | ssh-keygen |
Generates, manages, and converts authentication keys for ssh. |
| Tool | ssh-copy-id |
Installs your public key in a remote machine's authorized_keys. |
3. Practical Examples
① Standard Connection
ssh admin@10.0.0.5
② Connecting with a Key Pair (Common for AWS/GCP)
ssh -i ~/keys/server_key.pem ec2-user@public-ip
③ Executing Remote Commands
ssh user@host "uptime"
4. [Tip] The .ssh Directory
Important files are usually located in ~/.ssh/:
* id_rsa: Your private key (NEVER share this!)
* id_rsa.pub: Your public key (Safe to share/upload to servers).
* known_hosts: A list of hosts you have successfully connected to before.
* authorized_keys: A list of public keys allowed to log into the server.