How to SSH into a Server from a Windows Machine Using PuTTY
Objective
Learn how to use PuTTY, a free SSH client for Windows, to securely connect to a remote server. This lab covers setting up PuTTY, establishing an SSH connection, and troubleshooting common issues.
Prerequisites
- PuTTY Installed on Your Windows Machine:
- Download PuTTY from the official website: https://www.putty.org.
- Install PuTTY by running the downloaded
.msi
file and following the on-screen instructions.
- Access to a Remote Server:
- Ensure you have the following information:
- Server IP/Hostname: e.g.,
192.168.1.100
orexample.com
. - Username: e.g.,
admin
. - Password or Private Key for authentication.
- Server IP/Hostname: e.g.,
- SSH must be enabled on the remote server.
- Ensure you have the following information:
- Basic Understanding of SSH:
- SSH (Secure Shell) is a protocol for securely accessing and managing remote systems over a network.
Step 1: Launching PuTTY
- Open PuTTY from the Start Menu or search for
PuTTY
in the Windows search bar. - You’ll see the PuTTY Configuration window, which is the central hub for setting up SSH connections.
Step 2: Configuring the SSH Connection
- In the Session category:
- Host Name (or IP address): Enter the server’s IP or hostname (e.g.,
192.168.1.100
). - Port: Use
22
(default SSH port). - Connection Type: Ensure SSH is selected.
- Host Name (or IP address): Enter the server’s IP or hostname (e.g.,
- Save the configuration for future use:
- Enter a name in the Saved Sessions field (e.g.,
MyServer
). - Click Save.
Tip: Saved sessions allow you to quickly reconnect without re-entering details.
- Enter a name in the Saved Sessions field (e.g.,
Step 3: Establishing the Connection
- Click Open to start the SSH session.
- A terminal window will open, and you may see a security alert:
- If it’s your first time connecting to the server, PuTTY will display the server’s SSH fingerprint.
- Click Yes to accept and save the server’s key.
- Enter your credentials:
- Username: Type your username and press Enter.
- Password: Enter your password (you won’t see it displayed) and press Enter.
Insight: Once authenticated, you’ll see a command-line interface for the remote server.
Step 4: Using SSH with Key-Based Authentication (Optional)
- Generate an SSH key pair (if not already done):
- Use a tool like PuTTYgen (bundled with PuTTY) to create a key pair:
- Open PuTTYgen and click Generate.
- Move your mouse randomly in the blank area to generate entropy.
- Save the private key (e.g.,
mykey.ppk
) and copy the public key.
- Use a tool like PuTTYgen (bundled with PuTTY) to create a key pair:
- Add the public key to the server:
- Append the public key to the
~/.ssh/authorized_keys
file on the remote server.
- Append the public key to the
- Configure PuTTY to use the private key:
- In the Connection > SSH > Auth category, click Browse under Private key file for authentication.
- Select your
.ppk
file.
- Save the session and connect.
Step 5: Troubleshooting Common Issues
- Connection Timeout:
- Ensure the server is online and accessible.
- Verify the server’s firewall allows SSH traffic on port
22
.
- Authentication Failed:
- Double-check your username and password.
- If using a key, ensure it matches the public key on the server.
- Server Host Key Changed:
- If you see a warning about a changed host key, it may indicate a security risk.
- Confirm with the server administrator before proceeding.
- Unable to Resolve Hostname:
- Ensure the server hostname is correct and DNS is functioning.
- Use the IP address if the hostname fails.
Step 6: Closing the Session
- To end the SSH session, type:
exit
- Close the PuTTY terminal window.
Additional Tips and Insights
- Command-Line Basics:
- Learn basic Linux commands to navigate and interact with the server.
- Port Forwarding:
- Use PuTTY for SSH tunneling or port forwarding by configuring the Connection > SSH > Tunnels settings.
- Secure the Server:
- Disable password authentication and use key-based authentication for enhanced security.
- Restrict SSH access to specific IPs or use a non-default port.
- Logging Sessions:
- Save session logs for auditing:
- Go to Session > Logging and configure logging options before connecting.
- Save session logs for auditing:
Key Takeaways
- PuTTY is a versatile tool for SSH access to remote servers from Windows machines.
- Understanding basic PuTTY configurations and SSH concepts ensures secure and efficient connections.
- Troubleshooting skills are essential for resolving common connectivity issues.