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 | 59 |
1 files changed, 46 insertions, 13 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 index e97995cc1..922aa09f5 100755 --- 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 @@ -1,15 +1,48 @@ #!/bin/sh -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 +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 |