# Append the hidden service configuration to the Torrc file
echo -e "HiddenServiceDir /var/lib/tor/onion-ssh/\nHiddenServicePort 22 127.0.0.1:22" > /etc/tor/torrc
Unless the '>' is changed to ">>", this will overwrite the torrc file. # Append the hidden service configuration to the Torrc file
echo -e "HiddenServiceDir /var/lib/tor/onion-ssh/\nHiddenServicePort 22 127.0.0.1:22" > /etc/tor/torrc
Unless the '>' is changed to ">>", this will overwrite the torrc file.Using ">" instead of ">>" means you don't end up with multiple copies of the same hidden service.
That said, I agree: it should append, but it should first check whether it has already added a hidden service to the file.
if [ $(grep "HiddenServicePort 22" /etc/tor/torrc | wc -l) -eq 0] if grep -q "HiddenServiceDir /var/lib/tor/onion-ssh/" /etc/tor/torrc