diff options
Diffstat (limited to 'meta-openbmc-mods/meta-common/recipes-core/dropbear/files')
-rwxr-xr-x | meta-openbmc-mods/meta-common/recipes-core/dropbear/files/enable-ssh.sh | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/meta-openbmc-mods/meta-common/recipes-core/dropbear/files/enable-ssh.sh b/meta-openbmc-mods/meta-common/recipes-core/dropbear/files/enable-ssh.sh new file mode 100755 index 000000000..922aa09f5 --- /dev/null +++ b/meta-openbmc-mods/meta-common/recipes-core/dropbear/files/enable-ssh.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +usage="$(basename "$0") [-h] [-d] -- Enable/Disable ssh for root user +where: + -h help + -d disable ssh and remove priv-admin permission for root user" + +enable_ssh() { + if [ -e /etc/systemd/system/dropbear@.service ] && + [ -e /etc/systemd/system/sockets.target.wants/dropbear.socket ]; then + echo "SSH is already enabled" + else + cp /usr/share/misc/dropbear@.service /etc/systemd/system/dropbear@.service + cp /usr/share/misc/dropbear.socket /etc/systemd/system/dropbear.socket + ln -s /etc/systemd/system/dropbear.socket /etc/systemd/system/sockets.target.wants/dropbear.socket + groupmems -g priv-admin -a root + systemctl daemon-reload + systemctl restart dropbear.socket + echo "Enabled SSH service for root user successful" + fi +} + +disable_ssh() { + if [ -e /etc/systemd/system/dropbear@.service ] && + [ -e /etc/systemd/system/sockets.target.wants/dropbear.socket ]; then + systemctl stop dropbear.socket + systemctl stop dropbear@*.service + rm -rf /etc/systemd/system/sockets.target.wants/dropbear.socket + rm -rf /etc/systemd/system/dropbear.socket + rm -rf /etc/systemd/system/dropbear@.service + groupmems -g priv-admin -d root + echo "SSH disabled" + else + echo "SSH is already disabled" + fi +} + +case "$1" in +"-h") + echo ${usage} + ;; +"-d") + disable_ssh + ;; +*) + enable_ssh + ;; +esac |