Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add option to disable ssh access for joinmarket
fixes: #52
- Loading branch information
Showing
3 changed files
with
70 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/bash | ||
|
||
if [ ${#1} -eq 0 ]||[ $1 = "-h" ]||[ $1 = "--help" ];then | ||
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 | ||
echo "joinmarketSSH=on" >> /home/joinmarket/joinin.conf | ||
fi | ||
|
||
echo | ||
if [ $1 = "off" ];then | ||
echo "# Disable ssh access with the joinmarket user" | ||
if ! grep -Eq "^DenyUsers joinmarket" /etc/ssh/sshd_config; then | ||
echo "DenyUsers joinmarket" >> /etc/ssh/sshd_config | ||
# set value in config | ||
sudo sed -i "s/^joinmarketSSH=.*/joinmarketSSH=off/g" /home/joinmarket/joinin.conf | ||
systemctl restart ssh | ||
fi | ||
elif [ $1 = "on" ]; then | ||
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 | ||
systemctl restart ssh | ||
else | ||
echo "# Invalid option $*" | ||
exit 1 | ||
fi |