SSH Basics and Key Authentication
How does SSH key authentication work? How do you set it up?
How does SSH key authentication work? How do you set it up?
SSH key authentication uses a public-private key pair. Generate keys with ssh-keygen, copy the public key (~/.ssh/id_rsa.pub) to the server's ~/.ssh/authorized_keys file using ssh-copy-id. The private key stays on your machine and should never be shared. Key auth is more secure than passwords and enables passwordless login.
SSH is the primary way to access remote servers securely. Understanding key-based authentication is essential for DevOps work, as it's used for server administration, Git operations, CI/CD pipelines, and automated deployments.
Generate and deploy SSH keys
SSH config file for easier access
- Setting wrong permissions on .ssh directory (should be 700) and authorized_keys (should be 600)
- Sharing or committing private keys to version control
- Not using a passphrase on private keys
- What's the difference between RSA, ECDSA, and Ed25519 keys?
- How do you use SSH agent to manage multiple keys?
- How would you set up SSH tunneling/port forwarding?
More Linux interview questions
Also worth your time on this topic
How to Find the IP Address of an SSH Client
Learn multiple ways to identify the IP address of clients connected to your SSH server, from environment variables to logs and active connection monitoring.
Securing Your Linux Server: Essential First Steps
Harden a fresh Ubuntu 24.04 server by creating a non-root user, locking down SSH, configuring a firewall with UFW, and setting up fail2ban to block brute-force attacks.
45 minutes
SSH Hardening Checklist
Comprehensive guide to harden your SSH server configuration and improve security.
30-45 minutes