SSH Overview: Concepts, Basic Commands, Port Forwarding, and Remote Operations
This article introduces SSH, explains its encryption-based login mechanism, demonstrates basic command syntax, shows practical examples of remote login, local/remote/dynamic port forwarding, remote command execution, and discusses common security concerns such as man‑in‑the‑middle attacks.
What is SSH? SSH (Secure Shell) is a network protocol that provides encrypted remote login between computers, originally designed in 1995 by Tatu Ylonen to replace plaintext communication and now a standard component of Linux systems.
Login principle – The client and server negotiate cryptographic keys, verify host authenticity via a public‑key fingerprint, and establish an encrypted channel for all subsequent traffic.
Basic usage – The typical command syntax is ssh -p 22 user@host . The -p option specifies a non‑default port; if the port is 22 it can be omitted, as can the username when it matches the local user.
Remote login example – Using two CentOS 6.5 VMs (192.168.13.135 and 192.168.13.138), the article shows how to check SSH service with netstat -ntlp | grep ssh and connect with ssh -p 22 [email protected] , handling the first‑time host key confirmation and password entry.
Port forwarding – SSH can forward TCP traffic, useful when firewalls block direct access. The article covers:
Local forwarding (client‑side): ssh -L [local_addr:]local_port:target_ip:target_port user@target_ip . Example: ssh -L 3306:127.0.0.1:3306 [email protected] to access a MySQL instance bound to localhost.
Remote forwarding (server‑side): ssh -R [remote_addr:]remote_port:target_ip:target_port user@remote_ip . Example: forwarding port 80 from a Windows host through an intermediate CentOS machine.
Dynamic forwarding (SOCKS proxy): ssh -D [local_addr:]local_port user@remote_ip , allowing all outgoing traffic to be tunneled through the SSH server.
Remote command execution – One‑liner syntax ssh user@host 'command' enables running commands on a remote host, e.g., ssh [email protected] 'uname -a' or transferring files with tar -cz test | ssh [email protected] 'tar -xz' .
Common issues – The article warns about man‑in‑the‑middle attacks when an attacker substitutes the host key, emphasizing the importance of verifying fingerprints because SSH lacks a built‑in certificate authority.
Conclusion – The guide provides a practical foundation for using SSH in everyday operations, covering login, command execution, and various forwarding techniques, while noting that deeper protocol analysis remains a topic for further study.
Top Architect
Top Architect focuses on sharing practical architecture knowledge, covering enterprise, system, website, large‑scale distributed, and high‑availability architectures, plus architecture adjustments using internet technologies. We welcome idea‑driven, sharing‑oriented architects to exchange and learn together.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.