Python'da, remote_server
numaralı SSH'ye bağlanmayı ve file
'u remote_server
'dan host_server
'a aktarmayı gerektiren bir komut dosyası yazıyorum. Herhangi bir uzak sunucu ve herhangi bir sunucu sunucusu kullanıcısı için çalışması gerektiğinden şifre kullanmam gerek.Parola olmadan paramiko ile uzak sunucuya nasıl bağlanır?
Kodum:
#get IP and username for remote access
IP = input("Enter host_server IP: ").split()
username = input("Enter username: ").split()
#password = ???????
#create a file on host_server for file
file_a = open(date+"file.txt", "a") #ignore the date variable
file = str(date+"file.txt")
#move file to host_server
import paramiko
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(IP[0], username = user[0], password = password[0])
print "Connected to server."
transfer = ssh.open_sftp()
transfer.get("file.txt", file)
transfer.close()
print "Transfer completed."
Soru: senaryo o parolasız kurar çalışan her zaman, böylece bir komut satırı terminali erişmeden komut dosyası içinde bir ortak anahtar kurmak için bir yolu var mı SSH ile erişim?