Вам нужно получить отчет с помощью команды ниже в файл /tmp/stdOtv.tmp
sftp -F /home/ub18/PktDstSSH/config remoteHostRoot <<-"heredoc" > /tmp/stdOtv.tmp
put /tmp/v8_Yohhbp_7/files/key1-cert.pub /etc/ssh/demons/sshd/keys/key_rsa_pkcs1_key-cert.pub
put /tmp/v8_Yohhbp_7/files/key2-cert.pub /etc/ssh/demons/sshd/keys/key_rsa_pkcs2_key-cert.pub
put /tmp/v8_Yohhbp_7/files/key3-cert.pub /etc/ssh/demons/sshd/keys/key_rsa_pkcs3_key-cert.pub
put /tmp/v8_Yohhbp_7/files/key4-cert.pub /etc/ssh/demons/sshd/keys/key_rsa_pkcs4_key-cert.pub
put /tmp/v8_Yohhbp_7/files/key5-cert.pub /etc/ssh/demons/sshd/keys/key_rsa_pkcs5_key-cert.pub
quit
heredoc
Вот что вы получите в /tmp/stdOtv.tmp
> sftp> progress
Progress meter enabled
sftp> put /tmp/v8_jQL7cg_7/files/key1-cert.pub /etc/ssh/demons/sshd/keys/key_rsa_pkcs1_key-cert.pub
Uploading /tmp/v8_jQL7cg_7/files/key1-cert.pub to /etc/ssh/demons/sshd/keys/key_rsa_pkcs1_key-cert.pub
sftp> put /tmp/v8_jQL7cg_7/files/key2-cert.pub /etc/ssh/demons/sshd/keys/key_rsa_pkcs2_key-cert.pub
Uploading /tmp/v8_jQL7cg_7/files/key2-cert.pub to /etc/ssh/demons/sshd/keys/key_rsa_pkcs2_key-cert.pub
sftp> put /tmp/v8_jQL7cg_7/files/key3-cert.pub /etc/ssh/demons/sshd/keys/key_rsa_pkcs3_key-cert.pub
Uploading /tmp/v8_jQL7cg_7/files/key3-cert.pub to /etc/ssh/demons/sshd/keys/key_rsa_pkcs3_key-cert.pub
sftp> put /tmp/v8_jQL7cg_7/files/key4-cert.pub /etc/ssh/demons/sshd/keys/key_rsa_pkcs4_key-cert.pub
Uploading /tmp/v8_jQL7cg_7/files/key4-cert.pub to /etc/ssh/demons/sshd/keys/key_rsa_pkcs4_key-cert.pub
sftp> put /tmp/v8_jQL7cg_7/files/key5-cert.pub /etc/ssh/demons/sshd/keys/key_rsa_pkcs5_key-cert.pub
Uploading /tmp/v8_jQL7cg_7/files/key5-cert.pub to /etc/ssh/demons/sshd/keys/key_rsa_pkcs5_key-cert.pub
sftp> quit
Нет строк прогресса с информацией о процентном соотношении объема и скорости передачи. Я попытался обернуть эту команду в скрипт.
script -qc 'sftp -F /home/ub18/PktDstSSH/config remoteHostRoot <<-"heredoc""
put /tmp/v8_26c0hp_7/files/key1-cert.pub /etc/ssh/demons/sshd/keys/key_rsa_pkcs1_key-cert.pub
put /tmp/v8_26c0hp_7/files/key2-cert.pub /etc/ssh/demons/sshd/keys/key_rsa_pkcs2_key-cert.pub
put /tmp/v8_26c0hp_7/files/key3-cert.pub /etc/ssh/demons/sshd/keys/key_rsa_pkcs3_key-cert.pub
put /tmp/v8_26c0hp_7/files/key4-cert.pub /etc/ssh/demons/sshd/keys/key_rsa_pkcs4_key-cert.pub
put /tmp/v8_26c0hp_7/files/key5-cert.pub /etc/ssh/demons/sshd/keys/key_rsa_pkcs5_key-cert.pub
quit
heredoc
' /tmp/stdOtv.tmp
В результате вывод файла ответов:
Script started on 2020-05-06 20:00:19+0300
Warning: Permanently added '192.168.1.201' (RSA) to the list of known hosts.
Connected to remoteHostRoot.
sftp> put /tmp/v8_Mp0Vbz_7/files/key1-cert.pub /etc/ssh/demons/sshd/keys/key_rsa_pkcs1_key-cert.pub
Uploading /tmp/v8_Mp0Vbz_7/files/key1-cert.pub to /etc/ssh/demons/sshd/keys/key_rsa_pkcs1_key-cert.pub
/tmp/v8_Mp0Vbz_7/files/key1-cert.pub 0% 0 0.0KB/s --:-- ETA
/tmp/v8_Mp0Vbz_7/files/key1-cert.pub 100% 2454 1.7MB/s 00:00
sftp> put /tmp/v8_Mp0Vbz_7/files/key2-cert.pub /etc/ssh/demons/sshd/keys/key_rsa_pkcs2_key-cert.pub
Uploading /tmp/v8_Mp0Vbz_7/files/key2-cert.pub to /etc/ssh/demons/sshd/keys/key_rsa_pkcs2_key-cert.pub
/tmp/v8_Mp0Vbz_7/files/key2-cert.pub 0% 0 0.0KB/s --:-- ETA
/tmp/v8_Mp0Vbz_7/files/key2-cert.pub 100% 2454 1.7MB/s 00:00
sftp> put /tmp/v8_Mp0Vbz_7/files/key3-cert.pub /etc/ssh/demons/sshd/keys/key_rsa_pkcs3_key-cert.pub
Uploading /tmp/v8_Mp0Vbz_7/files/key3-cert.pub to /etc/ssh/demons/sshd/keys/key_rsa_pkcs3_key-cert.pub
/tmp/v8_Mp0Vbz_7/files/key3-cert.pub 0% 0 0.0KB/s --:-- ETA
/tmp/v8_Mp0Vbz_7/files/key3-cert.pub 100% 2454 2.3MB/s 00:00
sftp> put /tmp/v8_Mp0Vbz_7/files/key4-cert.pub /etc/ssh/demons/sshd/keys/key_rsa_pkcs4_key-cert.pub
Uploading /tmp/v8_Mp0Vbz_7/files/key4-cert.pub to /etc/ssh/demons/sshd/keys/key_rsa_pkcs4_key-cert.pub
/tmp/v8_Mp0Vbz_7/files/key4-cert.pub 0% 0 0.0KB/s --:-- ETA
/tmp/v8_Mp0Vbz_7/files/key4-cert.pub 100% 2454 2.4MB/s 00:00
sftp> put /tmp/v8_Mp0Vbz_7/files/key5-cert.pub /etc/ssh/demons/sshd/keys/key_rsa_pkcs5_key-cert.pub
Uploading /tmp/v8_Mp0Vbz_7/files/key5-cert.pub to /etc/ssh/demons/sshd/keys/key_rsa_pkcs5_key-cert.pub
/tmp/v8_Mp0Vbz_7/files/key5-cert.pub 0% 0 0.0KB/s --:-- ETA
/tmp/v8_Mp0Vbz_7/files/key5-cert.pub 100% 2454 2.5MB/s 00:00
sftp> quit
Script done on 2020-05-06 20:00:21+0300
Есть ли способы получить это более простым способом . Scp хромает с точки зрения безопасности (читал где-то), поэтому выбор пал на sftp. Команда интерпретатора вызывается из другой программы, и мне нужно отправить отчет о переданных файлах. спасибо