Просмотр исходного кода

Revert "Add support for SSH Keys to login over sftp"

This reverts commit 2b4fa1a2dc763028f48b3014df8fc00214d4a296.
Undo accidental commit. No review yet
Jaap Marcus 3 лет назад
Родитель
Сommit
0af62b92aa
2 измененных файлов с 2 добавлено и 122 удалено
  1. 2 62
      bin/v-add-backup-host
  2. 0 60
      func/backup.sh

+ 2 - 62
bin/v-add-backup-host

@@ -50,8 +50,6 @@ EOF
 
 # Defining sftp command function
 sftpc() {
-    if [ "$privatekey" != "yes" ]; then 
-    
     expect -f "-" <<EOF "$@"
         set count 0
         spawn /usr/bin/sftp -o StrictHostKeyChecking=no -o Port=$port $user@$host
@@ -100,52 +98,6 @@ sftpc() {
 
         exit \$rc
 EOF
-    else
-    expect -f "-" <<EOF "$@"
-            set count 0
-            spawn /usr/bin/sftp -o StrictHostKeyChecking=no -o Port=$port -i $raw_password $user@$host
-            expect {
-    
-                -re "Couldn't|(.*)disconnect|(.*)stalled|(.*)not found" {
-                    set count \$argc
-                    set output "Disconnected."
-                    set rc $E_FTP
-                    exp_continue
-                }
-    
-                -re ".*denied.*(publickey|password)." {
-                    set output "Permission denied, wrong publickey or password."
-                    set rc $E_CONNECT
-                }
-    
-                "sftp>" {
-                    if {\$count < \$argc} {
-                        set arg [lindex \$argv \$count]
-                        send "\$arg\r"
-                        incr count
-                    } else {
-                        send "exit\r"
-                        set output "Disconnected."
-                        if {[info exists rc] != 1} {
-                            set rc $OK
-                        }
-                    }
-                    exp_continue
-                }
-    
-                timeout {
-                    set output "Connection timeout."
-                    set rc $E_CONNECT
-                }
-            }
-    
-            if {[info exists output] == 1} {
-                puts "\$output"
-            }
-    
-            exit \$rc
-EOF
-    fi
 }
 
 #----------------------------------------------------------#
@@ -157,19 +109,7 @@ if [ "$type" != 'local' ];then
     is_format_valid 'host' 'path' 'port'
     is_type_valid  'sftp,ftp,b2' "$type"
     is_username_format_valid "$user" "username"
-    
-    privatekey="no"
-    if [ -f "$raw_password" ]; then
-        if [[ $(cat  "$raw_password" | grep "OPENSSH PRIVATE") ]]; then
-            privatekey="yes"
-            password="$raw_password"
-        else
-            is_password_valid    
-        fi   
-    else
-        is_password_valid
-    fi
-    
+    is_password_valid
     format_no_quotes "$password" "password"
     
     if [ "$type" = 'sftp' ]; then
@@ -284,7 +224,7 @@ fi
 # Adding backup host
 if [ $type != 'local' ] && [ $type != 'b2' ]; then
     new_timestamp
-    str="HOST='$host'\nUSERNAME='$user'\nPASSWORD='$password'\nPRIVATEKEY='$privatekey'"
+    str="HOST='$host'\nUSERNAME='$user'\nPASSWORD='$password'"
     str="$str\nBPATH='$path'\nPORT='$port'\nTIME='$time'\nDATE='$date'"
     echo -e "$str" > $HESTIA/conf/$type.backup.conf
     chmod 660 $HESTIA/conf/$type.backup.conf

+ 0 - 60
func/backup.sh

@@ -197,7 +197,6 @@ ftp_delete() {
 # SFTP Functions
 # sftp command function
 sftpc() {
-    if [ $PRIVATEKEY != "yes" ]; then
     expect -f "-" <<EOF "$@"
         set timeout 60
         set count 0
@@ -252,65 +251,6 @@ sftpc() {
 
     exit \$rc
 EOF
-
-else
-
-    expect -f "-" <<EOF "$@"
-        set timeout 60
-        set count 0
-        spawn /usr/bin/sftp -o StrictHostKeyChecking=no \
-            -o Port=$PORT -i $PASSWORD $USERNAME@$HOST
-        expect {
-            -nocase "password:" {
-                send "$PASSWORD\r"
-                exp_continue
-            }
-
-            -re "Couldn't|(.*)disconnect|(.*)stalled|(.*)not found" {
-                set count \$argc
-                set output "Disconnected."
-                set rc $E_FTP
-                exp_continue
-            }
-
-            -re ".*denied.*(publickey|password)." {
-                set output "Permission denied, wrong publickey or password."
-                set rc $E_CONNECT
-            }
-
-            -re "\[0-9]*%" {
-                exp_continue
-            }
-
-            "sftp>" {
-                if {\$count < \$argc} {
-                    set arg [lindex \$argv \$count]
-                    send "\$arg\r"
-                    incr count
-                } else {
-                    send "exit\r"
-                    set output "Disconnected."
-                    if {[info exists rc] != 1} {
-                        set rc $OK
-                    }
-                }
-                exp_continue
-            }
-
-            timeout {
-                set output "Connection timeout."
-                set rc $E_CONNECT
-            }
-        }
-
-        if {[info exists output] == 1} {
-            puts "\$output"
-        }
-
-    exit \$rc
-EOF
-
-fi
 }
 
 # SFTP backup download function