From f2522a1abe0bd31c1b70ecad47ae6c81238c24ac Mon Sep 17 00:00:00 2001 From: Joshua Rogers Date: Thu, 11 Jan 2024 23:56:09 +0700 Subject: [PATCH] Use -oPubkeyAcceptedKeyTypes=+ssh-rsa only if supported. --- Snake.nocomments.sh | 4 +++- Snake.sh | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Snake.nocomments.sh b/Snake.nocomments.sh index d80da67..0c68e3e 100755 --- a/Snake.nocomments.sh +++ b/Snake.nocomments.sh @@ -386,10 +386,12 @@ check_sshkeygen() { check_ssh_options() { local ssh_extra_options local ssh_extra_option -ssh_extra_options=(-oHostkeyAlgorithms=+ssh-rsa -oKexAlgorithms=+diffie-hellman-group1-sha1 -oPubkeyAcceptedKeyTypes=+ssh-rsa) +ssh_extra_options=(-oHostkeyAlgorithms=+ssh-rsa -oKexAlgorithms=+diffie-hellman-group1-sha1) for ssh_extra_option in "${ssh_extra_options[@]}"; do [[ $(ssh "$ssh_extra_option" 2>&1) =~ Bad\ protocol\ 2\ host\ key\ algorithms|Bad\ SSH2\ KexAlgorithms|Bad\ key\ types ]] || ssh_options+=("$ssh_extra_option") done +ssh_extra_options="-oPubkeyAcceptedKeyTypes=+ssh-rsa" +[[ $(ssh "$ssh_extra_option" 2>&1) =~ Bad\ configuration\ option|pubkeyacceptedkeytypes ]] || ssh_options+=("$ssh_extra_option") } init_current_ips() { local current_ip diff --git a/Snake.sh b/Snake.sh index 5eb27ee..f8c74fe 100755 --- a/Snake.sh +++ b/Snake.sh @@ -660,10 +660,12 @@ check_ssh_options() { local ssh_extra_options local ssh_extra_option - ssh_extra_options=(-oHostkeyAlgorithms=+ssh-rsa -oKexAlgorithms=+diffie-hellman-group1-sha1 -oPubkeyAcceptedKeyTypes=+ssh-rsa) + ssh_extra_options=(-oHostkeyAlgorithms=+ssh-rsa -oKexAlgorithms=+diffie-hellman-group1-sha1) for ssh_extra_option in "${ssh_extra_options[@]}"; do [[ $(ssh "$ssh_extra_option" 2>&1) =~ Bad\ protocol\ 2\ host\ key\ algorithms|Bad\ SSH2\ KexAlgorithms|Bad\ key\ types ]] || ssh_options+=("$ssh_extra_option") done + ssh_extra_options="-oPubkeyAcceptedKeyTypes=+ssh-rsa" + [[ $(ssh "$ssh_extra_option" 2>&1) =~ Bad\ configuration\ option|pubkeyacceptedkeytypes ]] || ssh_options+=("$ssh_extra_option") } # Determining the ip address of the current destination is difficult because it may have multiple ip addresses, and we are likely to connect to both of them eventually (including 127.0.0.1 for example).