Linux Terminal Command: ssh
The ssh command is an essential tool in Network Utilities. In this tutorial, we will explore what ssh does, look at everyday examples, and cover advanced options to supercharge your command-line workflow.
Concept & Explanation
The ssh command logs you into remote hosts securely using encrypted cryptographic keys or passwords.
Common Options & Syntax
ssh [options] [arguments]
Here are the most common flags used with ssh:
- Simple Usage: Basic default commands.
- Detailed View: Shows diagnostic information.
- Advanced Actions: Can chain parameters for scripting.
1. Interactive Example (Simple)
Here is how most people run the command:
# Example
ssh user@host.com
What it does: Connects to ‘host.com’ as ‘user’ using default port 22.
2. Power-User Example (Advanced)
For scripting and advanced diagnostics, use this configuration:
# Advanced
ssh -p 2222 -i ~/.ssh/id_rsa -N -L 8080:localhost:80 user@host.com
What it does: Connects via port 2222, uses a private key file (-i), disables shell execution (-N), and maps local port 8080 to remote port 80 (SSH port forwarding).
⚙️ Warning & Common Pitfalls
[!WARNING] If your private key permissions are too broad (e.g. 777), SSH will reject connection. Secure your private keys using
chmod 600 ~/.ssh/id_rsa.
🔗 Related Commands
Here are some related posts on cli_tty1 you might want to check out:
- chmod : Change file mode bits (permissions).