2021-06-20 22:13:02 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
2024-04-04 22:46:29 +02:00
|
|
|
if [ ${#1} -eq 0 ] || [ $1 = "-h" ] || [ $1 = "--help" ]; then
|
2021-06-20 22:13:02 +01:00
|
|
|
echo "Enable or disable ssh access with the joinmarket user"
|
|
|
|
|
echo "sudo set.ssh.sh [off|on]"
|
|
|
|
|
echo
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# check if sudo
|
|
|
|
|
if [ "$EUID" -ne 0 ]; then
|
|
|
|
|
echo "Please run as root or with sudo"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# add default value to config if needed
|
|
|
|
|
if ! grep -Eq "^joinmarketSSH=" /home/joinmarket/joinin.conf; then
|
2021-12-08 18:49:07 +00:00
|
|
|
echo "joinmarketSSH=on" | tee -a /home/joinmarket/joinin.conf
|
2021-06-20 22:13:02 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo
|
2024-04-04 22:46:29 +02:00
|
|
|
if [ "$1" = "off" ]; then
|
2021-06-20 22:13:02 +01:00
|
|
|
echo "# Disable ssh access with the joinmarket user"
|
|
|
|
|
if ! grep -Eq "^DenyUsers joinmarket" /etc/ssh/sshd_config; then
|
2021-12-08 18:49:07 +00:00
|
|
|
echo "DenyUsers joinmarket" | tee -a /etc/ssh/sshd_config
|
2021-06-20 22:13:02 +01:00
|
|
|
# set value in config
|
2021-12-08 18:49:07 +00:00
|
|
|
sed -i "s/^joinmarketSSH=.*/joinmarketSSH=off/g" /home/joinmarket/joinin.conf
|
|
|
|
|
service sshd restart
|
2021-06-20 22:13:02 +01:00
|
|
|
fi
|
2021-12-08 18:49:07 +00:00
|
|
|
elif [ "$1" = "on" ]; then
|
2021-06-20 22:13:02 +01:00
|
|
|
echo "# Enable ssh access with the joinmarket user"
|
|
|
|
|
sed -i "s/^DenyUsers joinmarket//g" /etc/ssh/sshd_config
|
|
|
|
|
# set value in config
|
|
|
|
|
sed -i "s/^joinmarketSSH=.*/joinmarketSSH=on/g" /home/joinmarket/joinin.conf
|
2021-12-08 18:49:07 +00:00
|
|
|
service sshd restart
|
2021-06-20 22:13:02 +01:00
|
|
|
else
|
|
|
|
|
echo "# Invalid option $*"
|
|
|
|
|
exit 1
|
2024-04-04 22:46:29 +02:00
|
|
|
fi
|