~/ssh-doctor
SSH Doctor
for rooted LG webOS TVs

SSH broke?
Fix it from the couch.

SSH on a rooted LG TV breaks in a handful of ways: a keys file with Windows line endings, a private key pasted by mistake, the alpine password gone after the first key, a host key warning after a reset. SSH Doctor finds out which one, in plain words, and fixes it with the remote. It runs through the Homebrew Channel, not over SSH, so it still works when SSH is completely broken. It also pairs a key from your phone or computer with a short code, and lets you set your own password, switch to keys only or move SSH to another port, all kept after a restart. It can bring SSH back by itself after a restart, tell you if your router exposes it to the internet, and save your setup to a USB drive for after a reset. Use Entware's OpenSSH or dropbear instead? It checks that too.

version v0.5.0 TV app Homebrew Channel ssh dropbear · Entware languages en · ru · es ★ 1 license MIT
$ ssh root@tv

Sound familiar?

The common ways SSH breaks on a rooted LG TV. None of them needs a factory reset.

ssh: connect to host 192.168.1.50 port 22: Connection refused root@192.168.1.50: Permission denied (publickey). PuTTY: No supported authentication methods available WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! Unable to negotiate: no matching host key type found
features

Check, fix, pair.

Every repair says what it will change and keeps a dated backup first.

The check

Whether SSH is on in the Homebrew Channel and really running on its port, how you can log in (password, keys, or nobody), whether authorized_keys is usable, telnet as a way back in, failsafe mode, and the TV's own key fingerprints.

One button per fix

Turn SSH on now without a restart, Fix my keys file (line endings, hidden characters, wrapped and PuTTY keys, private keys, permissions), Go back to password login for anyone locked out, and Undo a change.

QR

Pair a key by code

Scan the QR on the TV, type the short code, and send a key you have or let the browser make one. The private key never leaves your phone or computer.

Entware's SSH too

When Entware's OpenSSH or dropbear is how you log in, it counts as your SSH and gets checked: its settings, root login, whether a password works there, host keys, its port and starting at boot. It also spots Developer Mode's SSH on 9922, and only ever changes the Homebrew Channel's server.

$_

Works over telnet too

ssh-doctor.sh runs on its own, for when telnet is the only way in: status, fix-keys, password-on and the rest.

dropbear -p 2222 -s -K 30

SSH settings that stick.

dropbear has no settings file: its options are set when it starts, and the Homebrew Channel starts it with none. SSH Doctor keeps yours and puts them back after every restart, with a small startup script in /var/lib/webosbrew/init.d.

The SSH settings menu: your own password, keys only, SSH port and keep idle sessions connected
***

Your own password

Typed on the TV, or on your phone through the pairing page. It's turned into a SHA-512 crypt hash first, so the password itself is never sent over your network or saved on the TV, and applied the way the Homebrew Channel applies alpine.

#

Keys only

Passwords stop logging in. It won't turn on until a key is on the TV, and Go back to password login undoes it if you lose the key.

:22

Another port

2222, 22022 or any free port. The old port stays open until you've logged in on the new one and keep it, and if dropbear won't start there, SSH goes straight back.

♥

Keepalive and reset

A keepalive every 30 seconds so routers don't drop quiet sessions, and Reset to Homebrew Channel defaults removes all of it, the startup script too.

more tools

Who's been logging in?

Recent logins and failed tries from the TV's own log, with a warning when the tries come from outside your home network.

Login history: logins by key and password, and failed tries, with where they came from

Keys on this TV

Each key with its name, fingerprint and when it last logged in. Rename or remove one, with a backup.

The TV's own keys

Fingerprints to check a first login against, or make new ones if they're broken.

Telnet off

The Homebrew Channel's telnet lets anyone on your network in as root with no password. Turn it off once SSH works, or back on.

Report for help

A QR code with a short report, no addresses, keys or names in it, ready to paste into a GitHub issue or a forum post.

scan → copy

Copy it on your phone.

No typing long commands off the TV. The screens with something worth copying show a QR code beside it.

How to log in on the TV, with a QR code to copy it on a phone
The copy page on a phone: the login command, an SSH config and the TV's known_hosts lines, each with a Copy button
QR

Everything, one tap each

How to log in, Report for getting help and the TV's fingerprints open a read-only page on your phone: the login command for Mac, Linux, Windows, PuTTY or SFTP, Open in an SSH app, the ssh-keygen -R line for a changed host key, an SSH config and the keys that can log in. It stops when that screen closes.

↓

Update from the app

Each time it opens, SSH Doctor checks GitHub for a newer release. Update to v… shows what's new and installs it through the Homebrew Channel, which checks the download's SHA-256 first. The app opens again by itself and shows what changed.

SFTP

File transfer, key or password

File transfer says how to log in from WinSCP, FileZilla or Cyberduck: with your key (and where each one takes it), alpine or your own password. The address shown is the main connection's, so a wired eth0 comes before Wi-Fi.

reboot · router · usb

Back by itself, closed to the internet, saved for later.

Three things that matter most right after a restart, a reset, or when the TV can be reached from outside.

↻

Fix SSH at startup

Turn it on in SSH settings and, after every restart, SSH Doctor checks that SSH came up. If it didn't, it starts it, and fixes keys file permissions dropbear would refuse. The main screen says when it had to. It never touches a port another program has.

↗

Reachable from the internet?

Each time the app opens, it asks your router (UPnP, the way games open ports) whether it forwards the TV's SSH or telnet to the internet. If it does, Close it on the router takes those forwards off. Telnet, root with no password, is flagged first.

USB

Save or restore my setup

Your keys, the TV's own SSH keys, settings and password hash on a USB drive. After a factory reset and rooting again, put them back: logins work as before, and computers don't warn REMOTE HOST IDENTIFICATION HAS CHANGED.

$_

Get more from SSH

No Entware on the TV yet? SSH Doctor points to it: bash with history and tab completion, tmux to keep work running after you disconnect, nano, vim, htop, git, rsync and hundreds more packages, from the same Homebrew Channel repo.

set up a key

No copying keys around.

The pairing page only runs while its screen is open on the TV, and nothing changes until you press OK on the remote.

Choose Set up a key

The TV shows a QR code, an address on port 28622 and a short code like K7F-3QX.

Scan it and type the code

On the phone or computer you'll log in from. Five wrong tries get a new code, and three rounds close the page.

Send a key, or make one

Upload the .pub file you have, or let the browser make an ed25519 key pair. Only the public half goes to the TV.

Check the fingerprint, press OK

The page then shows the exact command for Mac, Linux, Windows, PuTTY, SFTP or a phone app, plus a ready-made ~/.ssh/config entry and the TV's known_hosts lines.

The pairing page on a phone: make a key, or send one you haveThe pairing page on a phone, setting the TV's password
homebrew channel repo

Install it from the Homebrew Channel.

Add this repository once and SSH Doctor shows up in the Homebrew Channel's app list, next to TiviBro, LG-USB-2-ETH0 and Entware. New releases appear there as updates.

https://ohmybahgosh.dev/repo

Open the Homebrew Channel's settings

Open the Homebrew Channel and select the gear icon at the top right.

Add the repository

Scroll to Repositories, choose Add repository, enter https://ohmybahgosh.dev/repo and select Add repository.

Install, then open it

Go back to the app list, install SSH Doctor and open it. It needs root, which the Homebrew Channel already has.

Or install the IPK yourself: org.ohmybahgosh.sshdoctor_*.ipk is attached to every release.

telnet 192.168.1.50

Over telnet.

The script inside the app works on its own, which helps when telnet is the only way in.

S=/media/developer/apps/usr/palm/applications/org.ohmybahgosh.sshdoctor/assets/ssh-doctor.sh
sh $S status            # what's wrong, in plain words
sh $S ssh-on            # turn SSH on and start it now
sh $S fix-keys          # repair authorized_keys and its permissions
sh $S password-on       # back to user root, password alpine
sh $S set-port 2222     # then: port-keep, or port-revert
sh $S reset-settings    # back to the Homebrew Channel's defaults
sh $S entware           # Entware's OpenSSH and dropbear, checked
sh $S set-bootfix on    # check SSH at every start
sh $S exposure          # does the router forward SSH or telnet?
sh $S kit-save          # save to a USB drive; then kit-restore
sh $S update-check      # a newer release?  then update-install
sh $S report            # a report for asking for help
sh $S help              # everything else
diff /

Exactly what it changes.

Only when you press a button, with a backup first. System partitions are never written.

pathwhat
/home/root/.ssh/authorized_keysRepaired, added to, or set aside, always with a dated .ssh-doctor-* backup next to it
/etc/shadowNever written: root's password goes through a bind-mounted copy in /tmp, the way the Homebrew Channel sets alpine
/var/lib/webosbrew/ssh-doctorYour SSH settings, and your password's hash (readable by root only)
/var/lib/webosbrew/init.d/60-ssh-doctorStartup script that restarts the Homebrew Channel's dropbear with your settings. Only there while a setting is on
/var/luna/preferences/webosbrew_*The Homebrew Channel's own SSH and telnet switches, only when you turn them on or off
/var/lib/webosbrew/sshdThe TV's host keys, only if you make new ones or put saved ones back (backed up first)
/tmp/usb/…/ssh-doctor-kitYour saved setup, only when you save one to a USB drive. It holds the TV's private SSH keys, so keep the drive safe
your routerAsked which ports it forwards (UPnP). Only Close it on the router changes it, and only the forwards to this TV's SSH or telnet
the app itselfUpdated only when you choose Update to v…, through the Homebrew Channel, which checks the download from GitHub against its SHA-256 first
/opt/etcEntware's SSH settings, host keys and password file: only read, never changed. OpenSSH is asked for its settings with sshd -T, which only reads them
faq

Questions.

I added a key and now alpine doesn't work. Is something broken?
No, that's the Homebrew Channel on purpose: at startup it only turns alpine on when there's no keys file. If the key doesn't work either, open SSH Doctor and choose Fix my keys file, or Go back to password login.
Can I lock myself out with the settings?
It's hard to. Open SSH sessions stay connected when settings restart SSH. Keys only won't turn on without a key, a port change keeps the old port open until you keep the new one, and the app itself runs through the Homebrew Channel, so Go back to password login always works from the remote.
Does my password go over the network?
No. The TV app or the pairing page turns it into a SHA-512 crypt hash first, and only the hash is sent and kept.
I use Entware's OpenSSH. Will it touch that?
It never changes, starts or stops it. When Entware's OpenSSH or dropbear is how you log in, SSH Doctor treats it as your SSH and checks it: whether OpenSSH accepts its settings, whether root may log in, whether a password works there (OpenSSH turns root's password off by default, and Entware keeps its own password file, /opt/etc/shadow), its host keys, its port, and whether Entware starts at boot. Set up a key works for it too, since it reads the same keys file.
Can I copy the login command on my phone instead of typing it?
Yes. How to log in, Report for getting help and the TV's fingerprints show a QR code. Scan it and your phone opens a page with everything ready to copy, one tap each. On a computer, type the address and the code it shows. It's read only and stops when you close that screen.
How do I update SSH Doctor?
From the app. It checks GitHub each time it opens and offers Update to v… with what's new. The Homebrew Channel installs it after checking the download's SHA-256, then SSH Doctor opens again and shows what changed. More tools, Updates checks by hand, and the Homebrew Channel's own update works too.
Was this written by AI?
It's written with AI coding agents (Claude), directed, reviewed and tested by me. The script has a test suite that runs every check and repair against a fake TV under busybox sh, dash and bash, CI drives the TV app and the pairing page in a browser, and each release is tried on a real TV. How these are built.
need a hand?

Stuck, found a bug, or got an idea?

The wiki covers every common SSH error. Pick a template and it fills in the right GitHub form for you. More tools, Report for getting help in the TV app gives you a report to paste in. For anything private, email me.

git tag --sort=-creatordate

Release notes.

Every release and what changed, pulled from GitHub automatically.

all releases ↗

loading releases…