SSH updates

This commit is contained in:
Zach Brown
2024-04-09 15:48:46 +00:00
parent c82d9496a7
commit 74790da711
3 changed files with 52 additions and 28 deletions

View File

@@ -431,34 +431,34 @@ install_simple_admin() {
mkdir $SIMPLE_ADMIN_DIR/www/css mkdir $SIMPLE_ADMIN_DIR/www/css
mkdir $SIMPLE_ADMIN_DIR/www/js mkdir $SIMPLE_ADMIN_DIR/www/js
cd $SIMPLE_ADMIN_DIR/systemd cd $SIMPLE_ADMIN_DIR/systemd
wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/development/simpleadmin/systemd/simpleadmin_generate_status.service wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/systemd/simpleadmin_generate_status.service
sleep 1 sleep 1
cd $SIMPLE_ADMIN_DIR/scripts cd $SIMPLE_ADMIN_DIR/scripts
wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/development/simpleadmin/scripts/build_modem_status wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/scripts/build_modem_status
wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/development/simpleadmin/scripts/modemstatus_parse.sh wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/scripts/modemstatus_parse.sh
wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/development/simpleadmin/scripts/tojson.sh wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/scripts/tojson.sh
sleep 1 sleep 1
cd $SIMPLE_ADMIN_DIR/www cd $SIMPLE_ADMIN_DIR/www
wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/development/simpleadmin/www/atcommander.html wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/atcommander.html
wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/development/simpleadmin/www/index.html wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/index.html
wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/development/simpleadmin/www/speedtest.html wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/speedtest.html
wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/development/simpleadmin/www/styles.css wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/styles.css
wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/development/simpleadmin/www/ttl.html wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/ttl.html
wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/development/simpleadmin/www/sms.html wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/sms.html
wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/development/simpleadmin/www/bandlock.html wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/bandlock.html
sleep 1 sleep 1
cd $SIMPLE_ADMIN_DIR/www/js cd $SIMPLE_ADMIN_DIR/www/js
wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/development/simpleadmin/www/js/alpinejs.min.js wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/js/alpinejs.min.js
sleep 1 sleep 1
cd $SIMPLE_ADMIN_DIR/www/css cd $SIMPLE_ADMIN_DIR/www/css
wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/development/simpleadmin/www/css/admin.css wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/css/admin.css
wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/development/simpleadmin/www/css/bulma.css wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/css/bulma.css
sleep 1 sleep 1
cd $SIMPLE_ADMIN_DIR/www/cgi-bin cd $SIMPLE_ADMIN_DIR/www/cgi-bin
wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/development/simpleadmin/www/cgi-bin/get_atcommand wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/cgi-bin/get_atcommand
wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/development/simpleadmin/www/cgi-bin/get_csq wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/cgi-bin/get_csq
wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/development/simpleadmin/www/cgi-bin/get_ttl_status wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/cgi-bin/get_ttl_status
wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/development/simpleadmin/www/cgi-bin/set_ttl wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/cgi-bin/set_ttl
sleep 1 sleep 1
cd / cd /
chmod +x $SIMPLE_ADMIN_DIR/scripts/* chmod +x $SIMPLE_ADMIN_DIR/scripts/*
@@ -1017,7 +1017,8 @@ echo " :+##+. "
echo -e "\e[96m8) Install/Update/Uninstall TTYd 1.7.4 (Uses port 443, No TLS/SSL)\e[0m" # Cyan echo -e "\e[96m8) Install/Update/Uninstall TTYd 1.7.4 (Uses port 443, No TLS/SSL)\e[0m" # Cyan
echo -e "\e[92m9) Install Speedtest.net CLI app (speedtest command)\e[0m" # Light Green echo -e "\e[92m9) Install Speedtest.net CLI app (speedtest command)\e[0m" # Light Green
echo -e "\e[92m10) Install Fast.com CLI app (fast command)(tops out at 40Mbps)\e[0m" # Light Green echo -e "\e[92m10) Install Fast.com CLI app (fast command)(tops out at 40Mbps)\e[0m" # Light Green
echo -e "\e[93m11) Exit\e[0m" # Yellow (repeated color for exit option) echo -e "\e[92m11) Install OpenSSH Server\e[0m" # Light Green
echo -e "\e[93m12) Exit\e[0m" # Yellow (repeated color for exit option)
read -p "Enter your choice: " choice read -p "Enter your choice: " choice
case $choice in case $choice in
@@ -1094,6 +1095,27 @@ echo " :+##+. "
echo -e "\e[1;32mThe fast.com test tops out at 40Mbps on the modem\e[0m" echo -e "\e[1;32mThe fast.com test tops out at 40Mbps on the modem\e[0m"
;; ;;
11) 11)
echo -e "\e[1;32mOpenSSH Server\e[0m"
remount_rw
mkdir /usrdata/sshd
wget -O /usrdata/sshd/sshd.service "https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/sshd/sshd.service"
ln -sf "/usrdata/sshd/sshd.service" "/lib/systemd/system/sshd.service"
opkg install openssh-server-pam
/opt/bin/ssh-keygen -A
systemctl daemon-reload
systemctl enable sshd
sed -i "s/^.*UsePAM .*/UsePAM yes/" "/opt/etc/ssh/sshd_config"
sed -i "s/^.*PermitRootLogin .*/PermitRootLogin yes/" "/opt/etc/ssh/sshd_config"
adduser -u 106 -G nogroup -h /opt/var/run -s /bin/nologin -S -D -H sshd
systemctl start sshd
echo -e "\e[1;32mOpenSSH installed!!\e[0m"
;;
12)
echo -e "\e[1;32mGoodbye!\e[0m" echo -e "\e[1;32mGoodbye!\e[0m"
break break
;; ;;

View File

@@ -83,7 +83,9 @@ create_opt_mount() {
echo -e '\033[32mInfo: Setting up /opt mount to /usrdata/opt...\033[0m' echo -e '\033[32mInfo: Setting up /opt mount to /usrdata/opt...\033[0m'
cat <<EOF > /lib/systemd/system/opt.mount cat <<EOF > /lib/systemd/system/opt.mount
[Unit] [Unit]
Description=Bind /usrdata/opt to /opt After=systemrw.mount sockets.target
Before=basic.target
RequiresMountsFor=/usrdata
[Mount] [Mount]
What=/usrdata/opt What=/usrdata/opt
@@ -92,7 +94,7 @@ Type=none
Options=bind Options=bind
[Install] [Install]
WantedBy=local-fs.target WantedBy=basic.target local-fs.target
EOF EOF
systemctl daemon-reload systemctl daemon-reload
@@ -203,10 +205,10 @@ opkg update && opkg install shadow-login shadow-passwd
fi fi
# Replace the login and passwd binaries and set home for root to a writable directory # Replace the login and passwd binaries and set home for root to a writable directory
rm /opt/etc/shadow mv /etc/shadow /opt/etc/shadow
rm /opt/etc/passwd mv /etc/passwd /opt/etc/passwd
ln -s /etc/shadow /opt/etc/ ln -s /opt/etc/shadow /etc/shadow
ln -s /etc/passwd /opt/etc ln -s /opt/etc/passwd /etc/passwd
mkdir /usrdata/root mkdir /usrdata/root
mkdir /usrdata/root/bin mkdir /usrdata/root/bin
touch /usrdata/root/.profile touch /usrdata/root/.profile

View File

@@ -4,9 +4,9 @@ Documentation=man:sshd(8) man:sshd_config(5)
After=network.target After=network.target
[Service] [Service]
ExecStartPre=/opt/usr/sbin/sshd -t ExecStartPre=/opt/sbin/sshd -t
ExecStart=/opt/usr/sbin/sshd -D ExecStart=/opt/sbin/sshd -D
ExecReload=/opt/usr/sbin/sshd -t ExecReload=/opt/sbin/sshd -t
ExecReload=/bin/kill -HUP $MAINPID ExecReload=/bin/kill -HUP $MAINPID
KillMode=process KillMode=process
Restart=on-failure Restart=on-failure