After an upgrade of the macOS you sometimes will lose the capability to SSH into other computers/servers. The code below will add the needed pieces to be able to SSH again.
Bash
#!/bin/sh
if grep -Fxq "HostKeyAlgorithms +ssh-rsa" /etc/ssh/ssh_config; then
echo "This SSH fix is not needed"
else
echo "Applying SSH Fix"
echo "HostKeyAlgorithms +ssh-rsa" | sudo tee -a /etc/ssh/ssh_config
echo "SSH Fix Applied, you may need to close terminal and retry"
fi
if grep -Fxq "HostKeyAlgorithms +ssh-rsa,ssh-dss" /etc/ssh/ssh_config; then
echo "Applying SSH Fix"
sudo sed -i.bak "s|HostKeyAlgorithms +ssh-rsa,ssh-dss|HostKeyAlgorithms +ssh-rsa|g" /etc/ssh/ssh_config
echo "SSH Fix Applied, you may need to close terminal and retry"
else
echo "This SSH fix is not needed"
fiPlease note that some sites will state to do ‘HostKeyAlgorithms +ssh-rsa,ssh-dss’ but ssh-dss was discontinued in 2015 and mostly should not work.
Originally Posted on September 27, 2025
Last Updated on October 14, 2025
Last Updated on October 14, 2025
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.