Basic SSH Connection
Remote Command Execution Syntax
Environment Variables
File Operations
Interactive Sessions
Background Processes
SSH Options
X11 Forwarding
Port Forwarding
Security
Troubleshooting
Best Practices
- Always use quotes around remote commands
- Use double quotes when variable expansion is needed
- Use single quotes for literal strings
- Consider using
nohup
or screen
/tmux
for long-running processes
- Always handle error cases in scripts
- Use SSH config file for frequently used connections
- Implement proper key management
- Use SSH agent for key management
SSH Config File Example