There are a large number of old linux devices. I am trying to write a program to automatically copy its configuration. shh public key authentication doesn't work, but rsync is there. I cannot send a password to the opening session. I'm trying to use Popen, but I can't seem to get the stdin sent to the process. Security is not important in this case, because the network is isolated.
def syncdevice(ip):
session = Popen([f'rsync -a user@{ip}:/mnt/usr /home/d400/ftp/{year}/{mounth}/{ip}/'], stdin=PIPE, stdout=PIPE, shell=True, universal_newlines=True)
return session
syncdevice('192.168.0.1')
session.stdin.write('password\n')
I try other functions like "communicate()", but in not effected also.