How to use SSH for remote access in Linux

· Category: Linux

Short answer

SSH provides encrypted remote shell access. Use key-based authentication for stronger security than passwords.

Steps

  1. Connect to a server:
ssh [email protected]
  1. Generate a key pair:
ssh-keygen -t ed25519 -C "[email protected]"
  1. Copy public key:
ssh-copy-id [email protected]
  1. Use a config file (~/.ssh/config):
Host myserver
  HostName server.example.com
  User admin
  IdentityFile ~/.ssh/id_ed25519

Tips

  • Disable root login and password authentication in /etc/ssh/sshd_config.
  • Use ssh -L for local port forwarding.
  • Keep private keys encrypted and never share them.

Common issues

  • Permission too open: private keys must be chmod 600.
  • Connection refused: verify the server is running sshd and the port is open.