Sending a password over SSH or SCP with subprocess.Popen

后端 未结 6 1292
-上瘾入骨i
-上瘾入骨i 2020-12-01 17:13

I\'m trying to run an scp (secure copy) command using subprocess.Popen. The login requires that I send a password:

from subprocess import Popen         


        
6条回答
  •  旧时难觅i
    2020-12-01 17:16

    I guess some applications interact with the user using stdin and some applications interact using terminal. In this case when we write the password using PIPE we are writing to stdin. But SCP application reads the password from terminal. As subprocess cannot interact with user using terminal but can only interact using stdin we cannot use the subprocess module and we must use pexpect for copying the file using scp.

    Feel free for corrections.

提交回复
热议问题