Connecting to a Linux System via SSH
Introduction
SSH (Secure Shell) is the standard protocol used to securely access remote Linux systems. It provides:
- Encrypted communication over the network
- Command-line access to remote systems
- Secure file transfer capabilities
Instead of passwords, many systems use SSH keys for authentication. A key pair consists of:
- A private key (kept on your machine, must be protected)
- A public key (stored on the server)
When you connect, SSH verifies that your private key matches the public key on the server.
Basic SSH Connection
The standard command is:
ssh -i <path-to-private-key> <user>@<hostname>
Example:
ssh -i mykey.pem root@myhost.domino-lab.net
Notes:
<user>is the remote user (e.g.root,ubuntu,admin)<hostname>is the server name or IP address- The
-ioption specifies your private key
macOS and Linux (Recommended Starting Point)
Both systems include a built-in SSH client.
Set Key Permissions
SSH requires that your private key is only accessible by you:
chmod 600 mykey.pem
If permissions are too open, SSH will refuse to use the key.
Connect
ssh -i mykey.pem user@hostname
Windows with MobaXterm (Recommended Option)
MobaXterm provides an easy graphical interface.
There is a MobaXterm Home edition which provides a portable edition, which does not need installation. It just needs to be extracted and started.
Steps:
- Start MobaXterm
- Click “Session” → “SSH”
- Enter your hostname
- Specify the remote user
- Enable “Use private key” and select your key file
- Connect
MobaXterm uses the standard OpenSSH key file PEM based format.
Windows with OpenSSH (Command Line)
Modern Windows versions include OpenSSH:
ssh -i mykey.pem user@hostname
Set Key Permissions (Important)
icacls ed25519 /inheritance:d
icacls ed25519 /remove "Authenticated Users" "Users" "Everyone"
icacls ed25519 /grant:r "%USERNAME%":R
This ensures only your user can read the key.
Windows with PuTTY / WinSCP (Advanced)
PuTTY
PuTTY requires its own key format (.ppk).
Convert Key
Use PuTTYgen to convert your key:
- Load your
.pemfile - Save as
.ppk
Configure Connection
- Open PuTTY
- Enter hostname
- Go to Connection → SSH → Auth
- Select your
.ppkfile - Connect
WinSCP
WinSCP is used for file transfers.
Steps:
- Enter hostname and username
- Select your private key file
- Connect using SCP or SFTP
Common Issues
Wrong Username
Always specify the remote user:
ssh user@hostname
Key Rejected
Check:
- Correct key file is used
- Permissions are restricted
- Public key is installed on the server
Permission Warning
If you see:
WARNING: UNPROTECTED PRIVATE KEY FILE!
Fix permissions as described above.
Summary
Typical command:
ssh -i mykey.pem user@hostname
Key points:
- SSH provides secure remote access
- Use key-based authentication when possible
- Ensure private key permissions are properly restricted