linux/ssh

Secure Shell Remote Login

Securely connect to remote systems using encrypted communication.

network
remote
security
encryption
linux

Command

ssh

Explanation

The `ssh` (Secure Shell) command establishes encrypted network connections to remote systems. It authenticates users with passwords or cryptographic keys and allows command execution or full terminal sessions. It also supports tunneling, forwarding, and agent-based authentication.

Common Use Cases

  • Remote server administration
  • Running commands on remote machines
  • Secure file transfers using `scp` or `sftp`

Best Practices

  • Use SSH key-based authentication instead of passwords
  • Disable root login in `/etc/ssh/sshd_config`
  • Regularly rotate SSH keys for security

Common Mistakes to Avoid

  • Incorrect file permissions on private keys
  • Forgetting to specify custom SSH ports

Troubleshooting

Problem: Permission denied (publickey)

Solution: Ensure the correct private key is used and permissions are set to 600.

Problem: Connection refused

Solution: Verify SSH service is running and firewall rules allow connections.

Examples

Connect to remote host as specified user

ssh user@host

Connect on a custom SSH port

ssh -p 2222 user@host

Authenticate with specific private key

ssh -i ~/.ssh/id_rsa user@host