Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

How to SSH into Your Server: Step-by-Step Guide

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

SSH (Secure Shell) lets you securely connect to your server's command line from anywhere, so you can manage files, install software, and configure services. This guide walks you through the standard SSH login process on Windows, macOS, and Linux. You'll need your server's IP address or hostname, your username, and your password or SSH key.

What You'll Need

  • Your server's IP address (e.g., 192.168.1.100) or hostname (e.g., server.example.com)
  • Your SSH username (often root or a user you created, like ubuntu)
  • Your password or a private SSH key (if you set up key-based authentication)
  • An SSH client: built into macOS and Linux; on Windows 10/11 you can use PowerShell or the Command Prompt (OpenSSH is preinstalled), or install PuTTY if you prefer a GUI

Step-by-Step

  1. Open your terminal or SSH client.
    • macOS/Linux: Open the Terminal app (on macOS, it's in Applications > Utilities).
    • Windows: Open PowerShell or Command Prompt. Alternatively, download and install PuTTY from the official site.
  2. Run the SSH command. Type the following and press Enter:
    ssh username@server_ip
    Replace username with your actual username and server_ip with your server's IP or hostname. For example:
    ssh admin@192.168.1.100
  3. Accept the host key (first time only). The first time you connect, you'll see a warning like:
    The authenticity of host '192.168.1.100' can't be established.
    Are you sure you want to continue connecting (yes/no)?
    Type yes and press Enter. This saves the server's fingerprint so future connections are verified.
  4. Enter your password. When prompted, type your password. You won't see any characters as you type (not even dots) – that's normal. Press Enter after typing it.
  5. You're in! Once authenticated, you'll see a shell prompt like user@server:~$. You can now run commands. To disconnect, type exit and press Enter.

Note: If you're using PuTTY, enter the hostname or IP in the "Host Name" field, keep port 22, select SSH, and click Open. Then follow the same authentication steps.

Common Mistakes

  • Wrong username or IP: Double-check that you're using the correct username and IP/hostname. A typo in either will fail.
  • Forgetting the port: SSH defaults to port 22. If your server uses a different port (e.g., 2222), you must specify it with -p (e.g., ssh -p 2222 user@server).
  • Typing password blindly: Many users think the terminal is frozen because no dots appear. It's working – just type and press Enter.
  • Using the wrong key file: If you're using an SSH key, you must specify the private key path with -i (e.g., ssh -i ~/.ssh/mykey.pem user@server).
  • Firewall blocking port 22: If the connection times out, your server's firewall or your local network may be blocking outbound SSH. Check with your host or network admin.

Tips

  • Use SSH keys instead of passwords: Keys are more secure and let you log in without typing a password. Generate a key pair on your local machine with ssh-keygen, then copy the public key to the server using ssh-copy-id user@server (on macOS/Linux) or manually append it to ~/.ssh/authorized_keys.
  • Create a config file for quick access: Add an entry in ~/.ssh/config like:
    Host myserver
        HostName 192.168.1.100
        User admin
        Port 22
    Then just type ssh myserver.
  • Keep your SSH client updated: Outdated clients may have security vulnerabilities. Update your OS or PuTTY regularly.
  • Use a password manager: If you must use passwords, store them securely in a password manager.

Troubleshooting

If your SSH connection fails, try these in order:

  1. Check for typos: Verify the username, IP, and port. A common error is Permission denied (publickey,password) – that means authentication failed, so check your credentials.
  2. Test basic connectivity: Use ping server_ip to see if the server is reachable. If ping fails, the server might be down or the network is blocking ICMP.
  3. Check if the SSH service is running: On the server (via a console or web panel), run sudo systemctl status ssh (or sshd). If it's not running, start it with sudo systemctl start ssh.
  4. Verify firewall rules: On the server, ensure port 22 is open. For example, on Ubuntu with UFW: sudo ufw allow 22/tcp. On cloud providers, check the security group settings.
  5. Try a different client: If you're using PuTTY, try the command line. If you're using a command line, try PuTTY. This isolates client-side issues.
  6. Check SSH logs: On the server, look at /var/log/auth.log (Debian/Ubuntu) or /var/log/secure (RHEL/CentOS) for error messages like "Connection refused" or "Invalid user".
  7. Restart the SSH service: If you have console access, restart SSH with sudo systemctl restart ssh. This can clear stuck connections.
  8. If all else fails, reboot the server: A reboot can resolve temporary network or service issues. Do this only if you have console access, and be aware it will drop all active connections.

Frequently Asked Questions

What is the default SSH port?

Port 22 is the standard SSH port. If your server uses a different port, you must specify it with -p.

How do I find my server's IP address?

If you're using a cloud provider, check their dashboard. On the server itself, run hostname -I (Linux) or ipconfig (Windows) to see local IPs. For a public IP, use a service like curl ifconfig.me from the server.

Can I SSH from my phone?

Yes, you can use apps like Termius (iOS/Android) or JuiceSSH (Android) from official app stores. They work the same way – enter the host, username, and password.

How do I copy files over SSH?

Use scp (secure copy). For example, to copy a file to the server: scp file.txt user@server:/path/. To copy from the server: scp user@server:/path/file.txt .

What if I get "Connection refused"?

That usually means the SSH service isn't running or the port is blocked. Check the service status and firewall rules on the server.

How do I change my SSH password?

Once logged in, run passwd and follow the prompts. You'll need your current password first.