From 4cb700f7725c53c0372c945a83649507b843ca03 Mon Sep 17 00:00:00 2001 From: mercury Date: Sat, 18 Feb 2023 00:35:57 +0400 Subject: [PATCH] fix ssh for ubuntu 22.04 --- app/bot.php | 12 ++++++------ dockerfile/shadowsocks.dockerfile | 4 ++-- scripts/start_ad.sh | 2 ++ scripts/start_ng.sh | 2 ++ scripts/start_proxy.sh | 2 ++ scripts/start_ss.sh | 2 ++ scripts/start_unit.sh | 1 + scripts/start_wg.sh | 2 ++ 8 files changed, 19 insertions(+), 8 deletions(-) diff --git a/app/bot.php b/app/bot.php index bae3bfe..c9118a3 100644 --- a/app/bot.php +++ b/app/bot.php @@ -55,7 +55,7 @@ class Bot if (empty($c['admin'])) { $c['admin'] = [$this->input['from']]; file_put_contents($file, "input['from'], $c['admin'])) { @@ -67,7 +67,7 @@ class Bot public function callbackCheck() { if (empty($this->callback) && !empty($this->input['callback_id'])) { - $this->answer($this->input['callback_id'], $GLOBALS['debug'] ? $this->input['callback']: false); + $this->answer($this->input['callback_id'], $GLOBALS['debug'] ? $this->input['callback'] : false); } } @@ -359,7 +359,7 @@ class Bot $this->menu('client', implode('_', $_SESSION['reply'][$this->input['reply']]['args'])); } - public function readClients():array + public function readClients(): array { return json_decode(file_get_contents($this->clients), true) ?: []; } @@ -1946,7 +1946,7 @@ DNS-over-HTTPS with IP: return $d; } - public function getName(array $a):string + public function getName(array $a): string { $name = ''; foreach ($a as $k => $v) { @@ -1989,7 +1989,7 @@ DNS-over-HTTPS with IP: } } $ip_count = (1 << (32 - $bitmask)) - count($ips) - 1; - for ($i=1; $i < $ip_count; $i++) { + for ($i = 1; $i < $ip_count; $i++) { $ip = $i + $server_ip; if (!in_array($ip, $ips)) { $client_ip = long2ip($ip); @@ -2109,7 +2109,7 @@ DNS-over-HTTPS with IP: CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => $json_header ? [ 'Content-Type: application/json' - ]: [], + ] : [], CURLOPT_POSTFIELDS => $data, ]); $res = curl_exec($ch); diff --git a/dockerfile/shadowsocks.dockerfile b/dockerfile/shadowsocks.dockerfile index 6a473dd..42fae44 100644 --- a/dockerfile/shadowsocks.dockerfile +++ b/dockerfile/shadowsocks.dockerfile @@ -3,12 +3,12 @@ arg RELEASE from ${SYSTEM}:${RELEASE} ENV DEBIAN_FRONTEND noninteractive run apt update && \ -apt install -y ssh git net-tools +apt install -y ssh git net-tools xz-utils run mkdir /root/.ssh && \ mkdir /ssh && \ touch /root/.ssh/authorized_keys && \ wget https://github.com/shadowsocks/shadowsocks-rust/releases/download/v1.15.2/shadowsocks-v1.15.2.x86_64-unknown-linux-gnu.tar.xz && \ tar -xf shadowsocks-v1.15.2.x86_64-unknown-linux-gnu.tar.xz && \ wget https://github.com/teddysun/v2ray-plugin/releases/download/v5.2.0/v2ray-plugin-linux-amd64-v5.2.0.tar.gz && \ -tar xf v2ray-plugin-linux-amd64-v5.2.0.tar.gz && \ +tar -xf v2ray-plugin-linux-amd64-v5.2.0.tar.gz && \ mv v2ray-plugin_linux_amd64 /usr/local/bin/v2ray-plugin diff --git a/scripts/start_ad.sh b/scripts/start_ad.sh index 706467d..38bc07b 100644 --- a/scripts/start_ad.sh +++ b/scripts/start_ad.sh @@ -1,4 +1,6 @@ cat /ssh/key.pub > /root/.ssh/authorized_keys +echo 'HostKeyAlgorithms +ssh-rsa' >> /etc/ssh/sshd_config +echo 'PubkeyAcceptedKeyTypes +ssh-rsa' >> /etc/ssh/sshd_config service ssh start /AdGuardHome/AdGuardHome -s install -c /opt/adguardhome/AdGuardHome.yaml -h 0.0.0.0 -w /opt/adguardhome/ tail -f /dev/null diff --git a/scripts/start_ng.sh b/scripts/start_ng.sh index 1eb1cb2..b1411d5 100644 --- a/scripts/start_ng.sh +++ b/scripts/start_ng.sh @@ -1,4 +1,6 @@ cat /ssh/key.pub > /root/.ssh/authorized_keys +echo 'HostKeyAlgorithms +ssh-rsa' >> /etc/ssh/sshd_config +echo 'PubkeyAcceptedKeyTypes +ssh-rsa' >> /etc/ssh/sshd_config service ssh start sed "s/ss:[0-9]\+/ss:$SSPORT/" /nginx_default.conf > change_port cat change_port > /nginx_default.conf diff --git a/scripts/start_proxy.sh b/scripts/start_proxy.sh index 36bea11..b2879ab 100644 --- a/scripts/start_proxy.sh +++ b/scripts/start_proxy.sh @@ -1,4 +1,6 @@ cat /ssh/key.pub > /root/.ssh/authorized_keys +echo 'HostKeyAlgorithms +ssh-rsa' >> /etc/ssh/sshd_config +echo 'PubkeyAcceptedKeyTypes +ssh-rsa' >> /etc/ssh/sshd_config service ssh start sed -n "s/\"server_port\": \([0-9]\+\),/\1/p" /config.json > current_port CURRENT_PORT=$(cat current_port | tr -d " ") diff --git a/scripts/start_ss.sh b/scripts/start_ss.sh index 9101df9..819a245 100644 --- a/scripts/start_ss.sh +++ b/scripts/start_ss.sh @@ -1,4 +1,6 @@ cat /ssh/key.pub > /root/.ssh/authorized_keys +echo 'HostKeyAlgorithms +ssh-rsa' >> /etc/ssh/sshd_config +echo 'PubkeyAcceptedKeyTypes +ssh-rsa' >> /etc/ssh/sshd_config service ssh start sed "s/\"server_port\": [0-9]\+/\"server_port\": $SSPORT/" /config.json > change_port cat change_port > /config.json diff --git a/scripts/start_unit.sh b/scripts/start_unit.sh index d1595f1..19f0861 100644 --- a/scripts/start_unit.sh +++ b/scripts/start_unit.sh @@ -1,3 +1,4 @@ +rm /ssh/key* ssh-keygen -m PEM -t rsa -f /ssh/key -N '' openssl req -newkey rsa:2048 -sha256 -nodes -x509 -days 365 -keyout /certs/self_private -out /certs/self_public -subj "/C=NN/ST=N/L=N/O=N/CN=$(curl https://ipinfo.io/ip)" php init.php diff --git a/scripts/start_wg.sh b/scripts/start_wg.sh index fe40cdf..28feac0 100644 --- a/scripts/start_wg.sh +++ b/scripts/start_wg.sh @@ -13,5 +13,7 @@ sed "s/ListenPort = [0-9]\+/ListenPort = $WGPORT/" /etc/wireguard/wg0.conf > cha cat change_port > /etc/wireguard/wg0.conf wg-quick up wg0 cat /ssh/key.pub > /root/.ssh/authorized_keys +echo 'HostKeyAlgorithms +ssh-rsa' >> /etc/ssh/sshd_config +echo 'PubkeyAcceptedKeyTypes +ssh-rsa' >> /etc/ssh/sshd_config service ssh start tail -f /dev/null