Strange problem in SFTP script
Posted: Tue Aug 17, 2021 1:10 pm
HI,
I'm using a SFTP script for some time, encountering no problems.
The script is as follows:
#!/usr/local/bin/expect -f
set timeout 500
spawn sftp $env(SSH_USER)@$env(SSH_HOST)
expect {
default {exit 2}
"continue connecting (yes/no/)?" {send "yes\n"; exp_continue}
"password:" {send "$env(SSH_PASS)\n"; exp_continue}
"sftp>" }
send "put $env(SSH_FILE_IN) $env(SSH_FILE_OUT)\n"
expect {
default {exit 2}
"not found" {exit 3}
"sftp>" }
send "quit\n"
exit 0
The usual response I get from the server (as appears in the log) is as follows (details were changed by Xs or random digits...):
spawn sftp xxxxxxxxxx@XXXXXXXXXX
........
The authenticity of host 'XXXXXXXXXX (01.002.003.04)' can't be established.
RSA key fingerprint is SHA256:xxxxxxxxxxxxxx.
Are you sure you want to continue connecting (yes/no)? yes
............
xxxxxxxxxx@XXXXXXXXXX's password:
Connected to XXXXXXXXXX.
etc.....
The important line is the one written in blue....
From about a week ago, I started to get a new response from the SFTP server:
Are you sure you want to continue connecting (yes/no/[fingerprint])?
The new addition ([fingerprint]) causes the script to get stuck and the "yes" answer does not get the response expected (to continue the script).
I tried to add the new text ([fingerprint]) to the script as follows:
expect {
default {exit 2}
"continue connecting (yes/no/[fingerprint])?" {send "yes\n"; exp_continue}
but the response I get is:
invalid command name "fingerprint"
while executing
"fingerprint"
invoked from within
"expect {
default {exit 2}
"continue connecting (yes/no/[fingerprint])?" {send "yes\n"; exp_continue}
"password:" {send "$env(SSH_PASS)\n"; ex..."
Have you encountered such a problem?
Do you have any idea as to how I can overcome this so the script will continue working as usual?
The problem is somewhat urgent, so I would be grateful for a response ASAP.
TIA.
Have a nice day.
Moti.
I'm using a SFTP script for some time, encountering no problems.
The script is as follows:
#!/usr/local/bin/expect -f
set timeout 500
spawn sftp $env(SSH_USER)@$env(SSH_HOST)
expect {
default {exit 2}
"continue connecting (yes/no/)?" {send "yes\n"; exp_continue}
"password:" {send "$env(SSH_PASS)\n"; exp_continue}
"sftp>" }
send "put $env(SSH_FILE_IN) $env(SSH_FILE_OUT)\n"
expect {
default {exit 2}
"not found" {exit 3}
"sftp>" }
send "quit\n"
exit 0
The usual response I get from the server (as appears in the log) is as follows (details were changed by Xs or random digits...):
spawn sftp xxxxxxxxxx@XXXXXXXXXX
........
The authenticity of host 'XXXXXXXXXX (01.002.003.04)' can't be established.
RSA key fingerprint is SHA256:xxxxxxxxxxxxxx.
Are you sure you want to continue connecting (yes/no)? yes
............
xxxxxxxxxx@XXXXXXXXXX's password:
Connected to XXXXXXXXXX.
etc.....
The important line is the one written in blue....
From about a week ago, I started to get a new response from the SFTP server:
Are you sure you want to continue connecting (yes/no/[fingerprint])?
The new addition ([fingerprint]) causes the script to get stuck and the "yes" answer does not get the response expected (to continue the script).
I tried to add the new text ([fingerprint]) to the script as follows:
expect {
default {exit 2}
"continue connecting (yes/no/[fingerprint])?" {send "yes\n"; exp_continue}
but the response I get is:
invalid command name "fingerprint"
while executing
"fingerprint"
invoked from within
"expect {
default {exit 2}
"continue connecting (yes/no/[fingerprint])?" {send "yes\n"; exp_continue}
"password:" {send "$env(SSH_PASS)\n"; ex..."
Have you encountered such a problem?
Do you have any idea as to how I can overcome this so the script will continue working as usual?
The problem is somewhat urgent, so I would be grateful for a response ASAP.
TIA.
Have a nice day.
Moti.