Skip to content

Commit 0af62b9

Browse files
committed
Revert "Add support for SSH Keys to login over sftp"
This reverts commit 2b4fa1a. Undo accidental commit. No review yet
1 parent df0da72 commit 0af62b9

File tree

2 files changed

+2
-122
lines changed

2 files changed

+2
-122
lines changed

bin/v-add-backup-host

Lines changed: 2 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ EOF
5050

5151
# Defining sftp command function
5252
sftpc() {
53-
if [ "$privatekey" != "yes" ]; then
54-
5553
expect -f "-" <<EOF "$@"
5654
set count 0
5755
spawn /usr/bin/sftp -o StrictHostKeyChecking=no -o Port=$port $user@$host
@@ -100,52 +98,6 @@ sftpc() {
10098
10199
exit \$rc
102100
EOF
103-
else
104-
expect -f "-" <<EOF "$@"
105-
set count 0
106-
spawn /usr/bin/sftp -o StrictHostKeyChecking=no -o Port=$port -i $raw_password $user@$host
107-
expect {
108-
109-
-re "Couldn't|(.*)disconnect|(.*)stalled|(.*)not found" {
110-
set count \$argc
111-
set output "Disconnected."
112-
set rc $E_FTP
113-
exp_continue
114-
}
115-
116-
-re ".*denied.*(publickey|password)." {
117-
set output "Permission denied, wrong publickey or password."
118-
set rc $E_CONNECT
119-
}
120-
121-
"sftp>" {
122-
if {\$count < \$argc} {
123-
set arg [lindex \$argv \$count]
124-
send "\$arg\r"
125-
incr count
126-
} else {
127-
send "exit\r"
128-
set output "Disconnected."
129-
if {[info exists rc] != 1} {
130-
set rc $OK
131-
}
132-
}
133-
exp_continue
134-
}
135-
136-
timeout {
137-
set output "Connection timeout."
138-
set rc $E_CONNECT
139-
}
140-
}
141-
142-
if {[info exists output] == 1} {
143-
puts "\$output"
144-
}
145-
146-
exit \$rc
147-
EOF
148-
fi
149101
}
150102

151103
#----------------------------------------------------------#
@@ -157,19 +109,7 @@ if [ "$type" != 'local' ];then
157109
is_format_valid 'host' 'path' 'port'
158110
is_type_valid 'sftp,ftp,b2' "$type"
159111
is_username_format_valid "$user" "username"
160-
161-
privatekey="no"
162-
if [ -f "$raw_password" ]; then
163-
if [[ $(cat "$raw_password" | grep "OPENSSH PRIVATE") ]]; then
164-
privatekey="yes"
165-
password="$raw_password"
166-
else
167-
is_password_valid
168-
fi
169-
else
170-
is_password_valid
171-
fi
172-
112+
is_password_valid
173113
format_no_quotes "$password" "password"
174114

175115
if [ "$type" = 'sftp' ]; then
@@ -284,7 +224,7 @@ fi
284224
# Adding backup host
285225
if [ $type != 'local' ] && [ $type != 'b2' ]; then
286226
new_timestamp
287-
str="HOST='$host'\nUSERNAME='$user'\nPASSWORD='$password'\nPRIVATEKEY='$privatekey'"
227+
str="HOST='$host'\nUSERNAME='$user'\nPASSWORD='$password'"
288228
str="$str\nBPATH='$path'\nPORT='$port'\nTIME='$time'\nDATE='$date'"
289229
echo -e "$str" > $HESTIA/conf/$type.backup.conf
290230
chmod 660 $HESTIA/conf/$type.backup.conf

func/backup.sh

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ ftp_delete() {
197197
# SFTP Functions
198198
# sftp command function
199199
sftpc() {
200-
if [ $PRIVATEKEY != "yes" ]; then
201200
expect -f "-" <<EOF "$@"
202201
set timeout 60
203202
set count 0
@@ -252,65 +251,6 @@ sftpc() {
252251
253252
exit \$rc
254253
EOF
255-
256-
else
257-
258-
expect -f "-" <<EOF "$@"
259-
set timeout 60
260-
set count 0
261-
spawn /usr/bin/sftp -o StrictHostKeyChecking=no \
262-
-o Port=$PORT -i $PASSWORD $USERNAME@$HOST
263-
expect {
264-
-nocase "password:" {
265-
send "$PASSWORD\r"
266-
exp_continue
267-
}
268-
269-
-re "Couldn't|(.*)disconnect|(.*)stalled|(.*)not found" {
270-
set count \$argc
271-
set output "Disconnected."
272-
set rc $E_FTP
273-
exp_continue
274-
}
275-
276-
-re ".*denied.*(publickey|password)." {
277-
set output "Permission denied, wrong publickey or password."
278-
set rc $E_CONNECT
279-
}
280-
281-
-re "\[0-9]*%" {
282-
exp_continue
283-
}
284-
285-
"sftp>" {
286-
if {\$count < \$argc} {
287-
set arg [lindex \$argv \$count]
288-
send "\$arg\r"
289-
incr count
290-
} else {
291-
send "exit\r"
292-
set output "Disconnected."
293-
if {[info exists rc] != 1} {
294-
set rc $OK
295-
}
296-
}
297-
exp_continue
298-
}
299-
300-
timeout {
301-
set output "Connection timeout."
302-
set rc $E_CONNECT
303-
}
304-
}
305-
306-
if {[info exists output] == 1} {
307-
puts "\$output"
308-
}
309-
310-
exit \$rc
311-
EOF
312-
313-
fi
314254
}
315255

316256
# SFTP backup download function

0 commit comments

Comments
 (0)