Upgrading a Cisco SG350-10P's Firmware Over SSH (the Hard Way)
Picked up a used Cisco SG350-10P PoE switch for the home lab, mainly to power a handful of IP cameras and an outdoor AP off a single box instead of a pile of PoE injectors. Before trusting it with anything camera-related, I wanted to see what state it was actually in — and it turned out to be running firmware from 2019, several versions behind. Here’s how the upgrade actually went over SSH, including the parts that didn’t work on the first try.
First Problem: SSH Wouldn’t Even Negotiate
A plain ssh to the switch failed before a password prompt ever showed up:
1
2
3
ssh [email protected]
# Unable to negotiate with 192.168.1.254 port 22: no matching key exchange method found.
# Their offer: diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1,diffie-hellman-group14-sha1
This firmware is old enough that modern OpenSSH refuses its key exchange algorithms by default. Forcing them back on gets past that:
1
2
3
4
ssh -o KexAlgorithms=diffie-hellman-group14-sha1 \
-o HostKeyAlgorithms=ssh-rsa \
-o Ciphers=aes128-ctr -o MACs=hmac-sha1 \
[email protected]
Tip: If you let the client negotiate its own preferred cipher instead of forcing one, it’ll pick chacha20-poly1305 and the switch disconnects mid-session with “Packet integrity error.” Force a plain cipher/MAC pair up front.
Second Problem: It’s Not Really SSH Auth
Even with the connection working, the switch authenticates the SSH session itself with no credentials at all, then prints a User Name: / Password: prompt inside the channel — Telnet riding on top of SSH. sshpass can’t help here since there’s nothing for it to hook into at the SSH layer; the password exchange happens after the session is already “authenticated.” Scripting it needed expect instead, answering both prompts as plain text over the open channel.
Tip: If you’re scripting against this kind of switch, don’t assume ssh -o PreferredAuthentications=password type flags do anything useful — the real prompt is just text in the terminal stream.
Picking the Right Firmware
Cisco’s 350 series is past End-of-Software-Maintenance, so whatever the latest build on software.cisco.com is, that’s the last one that’ll ever ship. Before grabbing it, I checked Cisco’s security advisories for anything tied to that release — there’s an SNMP denial-of-service bug listed against this exact firmware line, but it only applies to the larger 28P/52P/X switches with 60-watt PoE ports enabled, not the 10P. Worth the two minutes to check per-model before assuming an advisory against “your firmware version” actually applies to your hardware.
The Copy-Then-Boot Two-Step
The switch’s copy command pulls firmware over TFTP or SCP. TFTP is the simpler choice if you don’t want a real account password sitting in a command line — any machine with dnsmasq installed can serve as a disposable TFTP server for the transfer:
1
2
3
sudo dnsmasq --no-daemon --port=0 --enable-tftp \
--tftp-root=/path/to/firmware/dir \
--interface=<iface-facing-switch> --bind-interfaces
Then on the switch:
1
copy tftp://<admin-ip>/<firmware-file>.bin flash://image2
Tip: After this finishes, dir flash://system/images still shows only the old images — the new file just lands as a plain file at flash://image2, not inside the image directory. That had me double-checking whether the copy even worked before realizing it’s normal; the real install step is separate:
1
boot system flash://image2
This is what actually moves the file into flash://system/images/, and — critically — is what sets up proper dual-image fallback: show version afterward shows the new firmware as “Active after reboot” and the current one as “Inactive after reboot,” so a bad image never strands you without a way back.
Third Problem: Confirmation Prompts Eating Themselves
Scripting the reload confirmation cost two wasted attempts. Cisco’s CLI asks two Y/N questions in a row (unsaved changes, then the actual reload), and sending "Y\r" for the first one reliably made the second prompt default to N before my real answer arrived — expect would show the prompt, then (Y/N)[N] N appearing on its own, with my actual Y landing a beat later as an “Unrecognized command” at the regular prompt. Switching to a bare Y keystroke with no trailing \r fixed it:
1
2
expect -re {continue \? \(Y/N\)} { send "Y" }
expect -re {continue \? \(Y/N\)} { send "Y" }
Tip: If you’re matching prompt text to decide when to answer, match on the literal (Y/N) part, not an earlier substring of the same line — matching too early sends your keystroke before the prompt is actually ready to accept it.
The Lesson That Actually Cost Something
The switch warns outright before a reload: “You haven’t saved your changes.” I answered through it once without saving — the firmware upgrade itself was fine, but the SSH service toggle I’d enabled earlier reverted, and I had to re-enable it and log back in through the web UI to get CLI access back. The fix is one command, run before any reload:
1
copy running-config startup-config
Tip: Treat that warning as literal, not a formality. On a switch, “unsaved” means gone on the very next reboot — there’s no separate undo.
End Result
Old firmware (2.5.0.83, dated 2019) sitting as the inactive fallback image, new firmware active, SSH re-enabled and saved properly this time. The cameras and AP haven’t gone in yet — that’s VLAN planning for another post — but at least the switch itself is no longer five years behind before any of that starts.
