How to Connect to IoT Devices With SSH (Beginner’s Guide)

To connect to an IoT device with SSH, make sure SSH is turned on for the device, find its IP address on your network, and then open a terminal on your computer and type ssh username@device-ip, for example ssh admin@192.168.1.50. The first time, confirm the device’s key fingerprint by typing yes, then enter the password. Windows 10 and 11, macOS, and Linux all include an SSH client, so you don’t need to install anything. Before you rely on it, change any default password and switch to SSH keys.

This guide is for devices you own or manage, such as a Raspberry Pi, a home automation hub, or a network-attached sensor.

What you need

  • A device that supports SSH (most Linux-based single-board computers and many hubs do).
  • The device and your computer on the same network, or a secure way to reach it, like a VPN.
  • The device’s username and password, or an SSH key.

Step 1: Turn on SSH on the device

  • Raspberry Pi: In Raspberry Pi Imager, open the OS customization settings before writing the SD card, turn on Enable SSH, and set a username and password. On a running Pi, use sudo raspi-config > Interface Options > SSH.
  • Other devices: Look for an SSH, Remote access, or Developer setting in the device’s web interface or app. Some devices don’t allow SSH at all.

Step 2: Find the device’s IP address

  1. Sign in to your router’s admin page and look at the list of connected devices.
  2. Or check the device’s app or screen for its IP address.
  3. Many devices also answer to a local name, like raspberrypi.local.

Set a DHCP reservation in your router so the device keeps the same IP address.

Step 3: Connect with SSH

  1. On Windows, right-click Start and choose Terminal (or PowerShell). On a Mac, open Terminal.
  2. Type ssh username@192.168.1.50, replacing the username and IP with your device’s.
  3. The first time, you’ll see a message that the host’s authenticity can’t be established. Type yes to trust the device.
  4. Enter the password. You won’t see characters as you type.
Terminal window connecting to an IoT device with ssh, showing the host key fingerprint prompt and the device shell prompt
(1) Run the ssh command with the device’s username and IP, then (2) confirm the key fingerprint the first time you connect. (Illustration)

Type exit to disconnect. If the device uses a port other than 22, add -p and the port number, like ssh -p 2222 admin@192.168.1.50.

Step 4: Set up SSH keys (recommended)

  1. On your computer, run ssh-keygen -t ed25519 and press Enter to accept the defaults. Add a passphrase for extra protection.
  2. Copy your public key to the device. On Mac or Linux, run ssh-copy-id admin@192.168.1.50. On Windows, copy the contents of C:\Users\you\.ssh\id_ed25519.pub into ~/.ssh/authorized_keys on the device.
  3. Connect again. You should sign in with the key instead of a password.
  4. Once keys work, consider turning off password logins on the device by setting PasswordAuthentication no in /etc/ssh/sshd_config, then restarting SSH.

Keep IoT devices secure

  • Change default passwords immediately. Default credentials are a common way devices get compromised.
  • Don’t expose SSH to the internet. Avoid forwarding port 22 on your router. Use a VPN to reach devices remotely.
  • Keep the device updated. On Linux devices, run system updates regularly.
  • Put IoT devices on a separate network, like a guest or IoT network, if your router supports it.

Troubleshooting

  • “Connection refused”: SSH isn’t turned on, or it uses a different port.
  • “Connection timed out”: The IP address is wrong, the device is off, or you’re on a different network.
  • “Permission denied”: The username or password is wrong, or password logins are disabled.
  • “Host key verification failed”: The device was reset or replaced. If you’re sure it’s your device, remove the old key with ssh-keygen -R 192.168.1.50 and connect again.

Frequently asked questions

Do I need PuTTY on Windows?

No. Windows 10 and 11 include OpenSSH. PuTTY still works if you prefer a graphical app.

Can I copy files over SSH?

Yes. Use scp file.txt admin@192.168.1.50:/home/admin/, or an SFTP app.

Where can I learn more about SSH from Windows?

See how to SSH from Windows to Linux.