PuTTY

Download

PuTTY Tutorial: Connecting to Remote Servers

PuTTY is a free and open-source terminal emulator that supports various network protocols, including SSH, Telnet, and SCP. It is widely used to remotely connect to servers, manage devices, and transfer files. In this tutorial, we will guide you through the basic steps of using PuTTY to connect to a remote server via SSH.


Step 1: Download and Install PuTTY

  1. Download PuTTY:
    • Go to the official PuTTY website.
    • Download the appropriate version for your operating system (Windows, macOS, or Linux). For most Windows users, the 32-bit or 64-bit MSI installer is recommended.
  2. Install PuTTY:
    • After downloading, run the installer and follow the on-screen instructions to install PuTTY on your computer.
    • Once installed, you can open PuTTY from the start menu or desktop shortcut.

Step 2: Launch PuTTY and Configure Connection

  1. Open PuTTY:
    • Launch PuTTY. The PuTTY Configuration window will open.
  2. Enter Hostname or IP Address:
    • In the Session section (the default window), find the Host Name (or IP address) field.
    • Enter the hostname or IP address of the remote server you want to connect to. This is usually provided by your server provider or system administrator.
  3. Select Connection Type (SSH):
    • Under Connection Type, choose SSH. By default, the port number for SSH is 22. If your server uses a different port, change it accordingly.
  4. Saving the Session (Optional):
    • If you frequently connect to the same server, you can save the connection settings.
    • In the Saved Sessions field, enter a name for the session (e.g., “My Server”).
    • Click Save. This will allow you to easily connect to the same server in the future without re-entering the details.

Step 3: Connect to the Server

  1. Click Open:
    • Once the hostname and connection type are set, click the Open button at the bottom of the PuTTY window to initiate the connection.
  2. Accept SSH Key:
    • The first time you connect to a server, PuTTY will show a security alert about the server’s SSH key. This is normal. Verify the server’s fingerprint with your administrator if you’re unsure.
    • Click Yes to accept the key and continue the connection.
  3. Login with Username and Password:
    • A terminal window will appear, prompting you for a username.
    • Enter the username for the server and press Enter.
    • You will then be prompted for the password. Type the password (it will not show on screen for security reasons) and press Enter again.
  4. Successful Login:
    • If the username and password are correct, you will now be logged into the server, and you can begin issuing commands on the server’s terminal.

Step 4: Basic Commands in PuTTY

Once connected to a remote server via SSH, you can run various commands to manage files, users, or services on the server.

  1. File Management:
    • List files and directories: ls
    • Change directories: cd <directory>
    • Create a new directory: mkdir <directory-name>
    • Delete a file: rm <file-name>
    • Delete a directory: rm -r <directory-name>
  2. System Management:
    • Check system information: uname -a
    • Check disk usage: df -h
    • Restart a service (requires root): sudo systemctl restart <service>
  3. User Management:
    • Add a new user: sudo adduser <username>
    • Change the password for a user: sudo passwd <username>

Step 5: Using PuTTY to Transfer Files (Using PSCP)

PuTTY includes a command-line tool called PSCP (PuTTY Secure Copy), which allows file transfers between your local computer and the server.

  1. Download PSCP:
    • If you didn’t already install the full PuTTY package, download PSCP.exe from the PuTTY website.
  2. Transfer Files from Local to Remote:
    • Open a Command Prompt on your local computer.
    • Use the following syntax to upload a file:
      pscp C:\path\to\local\file username@server:/path/to/remote/directory
      
    • Example:
      pscp C:\Users\YourName\Documents\file.txt [email protected]:/home/user/
      
  3. Transfer Files from Remote to Local:
    • Use the following syntax to download a file from the server:
      pscp username@server:/path/to/remote/file C:\path\to\local\directory
      
    • Example:
      pscp [email protected]:/home/user/file.txt C:\Users\YourName\Documents\
      

Step 6: Generate SSH Keys for Passwordless Authentication

You can enhance security by using SSH keys instead of passwords to log in. Here’s how to set it up:

  1. Generate an SSH Key:
    • Open PuTTYgen (included with PuTTY).
    • Click Generate to create a new SSH key pair. Move your mouse around to generate randomness.
    • After the key is generated, set a key passphrase (optional for added security).
    • Click Save Private Key to save your private key on your local machine.
    • Copy the public key from the PuTTYgen window.
  2. Add the Public Key to the Remote Server:
    • Connect to the server using PuTTY and enter the following command to add your public key:
      nano ~/.ssh/authorized_keys
      
    • Paste the public key into the file, save, and exit.
  3. Configure PuTTY to Use the Private Key:
    • In PuTTY, go to the SSH > Auth section and click Browse to select your saved private key.
    • Now, whenever you connect to the server, PuTTY will use the SSH key for authentication.

Step 7: Disconnecting from the Server

  1. Exit the Terminal:
    • To disconnect from the remote server, simply type exit in the terminal window and press Enter.
  2. Close PuTTY:
    • Once disconnected, you can close the PuTTY terminal window.

Troubleshooting Common Issues

  1. Connection Refused:
    • Ensure that the server’s SSH service is running and that you’re using the correct IP address and port.
  2. Authentication Failure:
    • Double-check your username and password. If you’re using SSH keys, make sure the correct key is loaded.
  3. Timeouts or Slow Connections:
    • Check your internet connection, firewall settings, and server configuration. Try switching to a different protocol like Telnet or Rlogin for testing purposes.

Conclusion

PuTTY is a powerful tool for remotely managing servers and devices. Whether you’re transferring files, managing services, or running commands, PuTTY provides a secure and reliable way to connect to remote machines.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.