keepcalculator

06 Numbers and Powers

SSH for IoT: What Remote Access Gives You and What It Doesn’t

Card No. 06·39552 · Updated · Standard formula, shown below

SSH for IoT gives you a secure, encrypted command-line connection to a remote device, letting you run commands, transfer files, and manage configurations as if you were sitting at its console. What it does not give you is a graphical desktop, automatic firewall rules, or protection against misconfigured services—SSH is a secure transport, not a complete security solution. This article explains exactly what SSH can and cannot do for IoT devices, how to set it up correctly, and where its limits lie.

Background: Why SSH Matters for IoT

IoT devices—sensors, cameras, controllers, single-board computers—are often deployed in places you cannot physically reach. Updating firmware, changing Wi-Fi credentials, or debugging a crashed service over a serial cable is impractical when the device is mounted on a factory wall or in a weatherproof enclosure. SSH (Secure Shell) was created in 1995 by Tatu Ylönen as a replacement for insecure remote login protocols like Telnet and rsh. It has become the standard for remote administration of Unix-like systems, and most IoT operating systems (Raspberry Pi OS, Ubuntu Core, Yocto-based distros, OpenWrt) include an SSH server.

For IoT, SSH provides a way to reach a device over a network—LAN, VPN, or the internet—and execute commands in a shell. That simple capability enables remote troubleshooting, scripted deployments, and secure file transfers using SCP or SFTP. Without SSH, you would need physical access or a proprietary cloud portal for each device.

What SSH Gives You: Capabilities

SSH gives you a secure, encrypted channel between your computer and the IoT device. The core capabilities include:

  • Remote command execution – Run any command the device’s user account is allowed to run, e.g., systemctl restart sensor-service or python3 /opt/read_sensor.py.
  • Secure file transfer – Use scp or sftp to copy configuration files, logs, or firmware updates to and from the device.
  • Port forwarding (tunneling) – Forward a local port to a service on the IoT device, or vice versa, to access a web dashboard or a database that is not exposed directly.
  • Public key authentication – Log in with a cryptographic key pair instead of a password, enabling automation and stronger security.
  • Agent forwarding – Use your local SSH keys to authenticate to other servers from the IoT device (use with caution).

These features allow you to manage fleets of devices without physical contact. For example, you can write a script that SSHes into each device, pulls logs, and pushes a new configuration file—all over an encrypted connection.

What SSH Does NOT Give You: Limitations

SSH is not a remote desktop. It provides a text-based shell, not a graphical interface. If your IoT device runs a GUI application (like a camera viewer or a dashboard), SSH alone cannot show it—you would need X11 forwarding (slow and fragile) or a separate VNC/RDP solution over the SSH tunnel.

SSH also does not give you:

  • Automatic security – SSH encrypts the connection, but it does not patch vulnerabilities, configure firewalls, or block brute-force attacks. You must set up fail2ban, strong keys, and restrict access.
  • File synchronization – SSH transfers files on demand; it does not keep directories in sync like rsync (though rsync can run over SSH).
  • Discovery – SSH does not find devices on your network; you need to know the IP address or hostname, or use mDNS/ARP scanning.
  • Wake-on-LAN or power management – If the device is off or crashed, SSH cannot turn it on. You need out-of-band management (e.g., a smart power switch).
  • Guaranteed connectivity – SSH requires network reachability. If the device is behind NAT or a firewall, you may need a reverse tunnel or a VPN.

How SSH Works in IoT Contexts

SSH uses a client-server model. The IoT device runs an SSH daemon (sshd) that listens on TCP port 22 by default. The client (your laptop) initiates a connection, and the two sides negotiate encryption keys using a key exchange algorithm (e.g., Curve25519). Authentication typically uses either a password or a public key.

For IoT, the most common setup is:

  1. Install an SSH server on the device (e.g., apt install openssh-server on Debian-based systems).
  2. Generate a key pair on your client: ssh-keygen -t ed25519.
  3. Copy the public key to the device: ssh-copy-id user@device_ip.
  4. Disable password authentication in /etc/ssh/sshd_config for stronger security.
  5. Connect with ssh user@device_ip.

For devices behind NAT (e.g., a sensor on a cellular network), you can set up a reverse SSH tunnel to a public server: ssh -R 2222:localhost:22 user@public_server. Then you can connect to the public server on port 2222 and reach the IoT device.

Security Considerations Specific to IoT

IoT devices are often targeted by botnets because they are numerous and sometimes poorly secured. SSH on IoT requires special care:

  • Change default credentials – Many devices ship with default usernames like pi or root and passwords like raspberry. Change them immediately.
  • Use key-based authentication – Passwords can be brute-forced; keys are far stronger.
  • Disable root login – Set PermitRootLogin no in sshd_config.
  • Limit access by IP – Use firewall rules (e.g., ufw allow from 192.168.1.0/24 to any port 22) to restrict who can reach the SSH port.
  • Keep software updated – SSH daemon vulnerabilities are rare but do happen; update the device’s OS regularly.
  • Use a VPN for internet access – Instead of exposing SSH directly to the internet, connect to a VPN first and then SSH to the device’s private IP.

A common misconception is that SSH is “secure enough� on its own. In reality, SSH only protects the data in transit; it does nothing to prevent an attacker from exploiting other services on the device (e.g., an open HTTP port) or from using stolen credentials if you use weak passwords.

Common Problems and How to Avoid Them

When using SSH for IoT, you may encounter these issues:

  • Connection refused – The SSH daemon is not running or the port is blocked. Check systemctl status ssh and firewall rules.
  • Host key verification failed – This happens when the device’s host key changed (e.g., after reflashing). Remove the old key from ~/.ssh/known_hosts.
  • Slow login – Often caused by DNS reverse lookups. Set UseDNS no in sshd_config.
  • Broken pipe or timeout – Network instability; use ServerAliveInterval 30 in your SSH client config to keep the connection alive.
  • Permission denied (publickey) – The public key is not in ~/.ssh/authorized_keys on the device, or the file permissions are too open (must be 600 for the file, 700 for the directory).

Alternatives and Comparisons

SSH is not the only remote access option for IoT. Here is how it compares to others:

  • Telnet – Sends everything in plaintext; never use it over a network you do not fully trust.
  • VNC/RDP – Provide graphical access, but are heavier and often less secure; they are typically tunneled over SSH for security.
  • Cloud vendor portals – Many IoT platforms (AWS IoT, Azure IoT Hub) offer device management with secure tunnels, but they require vendor-specific agents and internet connectivity.
  • VPN – Gives you network-level access to all devices, not just SSH; often combined with SSH for individual device management.
  • Serial console – Works even when the network is down, but requires physical access.

SSH is the most lightweight and universally supported option for command-line administration. For graphical interfaces or zero-config remote access, you may need additional tools.

Frequently Asked Questions

Can I use SSH to access a device behind a firewall?

Yes, if you set up a reverse SSH tunnel. The IoT device initiates an outbound connection to a public server, which you then connect to. This bypasses inbound firewall restrictions, but requires a server you control.

Is SSH enough to secure my IoT device?

No. SSH secures the remote administration channel, but you must also secure other services, change default credentials, keep the OS patched, and restrict network access. SSH is a tool, not a security policy.

What is the difference between SSH and SSL/TLS?

SSH is a protocol for remote login and command execution; SSL/TLS is used to encrypt data between applications (like HTTPS). They use similar cryptographic principles but serve different purposes. SSH can be used to tunnel other protocols, but it is not a replacement for TLS in web services.

Can I run SSH on a microcontroller like an ESP32?

Yes, but it is unusual. ESP32 and similar microcontrollers have limited RAM and flash; running a full SSH server is heavy. Most use lightweight alternatives like ESP-IDF’s console over serial or a simple telnet-like service. For Linux-capable boards (Raspberry Pi, BeagleBone), SSH is standard.

How do I transfer files over SSH?

Use scp or sftp. For example, scp file.txt user@device:/home/user/ copies a file to the device. These use the same SSH authentication and encryption.

What port does SSH use?

By default, SSH uses TCP port 22. You can change it in the config, but that is security by obscurity and not recommended; instead, use firewall rules and key authentication.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →