Linux
linuxlinux-commandsReferenceBeginner
Secure Shell Client (ssh)
Connect securely to remote Linux servers, execute remote commands, and forward ports using ssh.
Verified: 2026-09-30
Tested on:linux Ubuntu 24.04 / Debian 12
Platforms:
linuxmacos
#linux#ssh#remote#devops#security
Command
ssh -i ~/.ssh/id_ed25519 user@hostname_or_ip
Short Description
ssh (Secure Shell) is a protocol and client utility for securely logging into remote systems and executing commands over encrypted channels.
Examples
1. Connect with Specific Key and Port
ssh -i ~/.ssh/id_ed25519 -p 2222 deployer@192.0.2.102. Execute Command on Remote Server Without Interactive Shell
ssh deployer@192.0.2.10 "sudo systemctl restart nginx && uptime"3. Local Port Forwarding (Access Remote Database Locally)
Forward local port 5433 to remote server's localhost 5432:
ssh -L 5433:localhost:5432 deployer@192.0.2.10 -NNow connect to localhost:5433 to query the remote PostgreSQL instance safely without exposing port 5432 to the public internet.