# scp_transfer.py
import sys
import paramiko
from scp import SCPClient

ssh_user = "edi"
ssh_host = "192.168.1.13"
ssh_port = 34322
ssh_path = "/volume1/DATAS/4DDocuments/WebOrders/FTP/"
private_key_path = "/home/rms/.ssh/id_rsa"  # chemin absolu côté serveur PHP

def transfer(file_path):
    key = paramiko.RSAKey.from_private_key_file(private_key_path)
    ssh = paramiko.SSHClient()
    ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    ssh.connect(ssh_host, port=ssh_port, username=ssh_user, pkey=key)
    with SCPClient(ssh.get_transport()) as scp:
        scp.put(file_path, remote_path=ssh_path)
    ssh.close()

if __name__ == "__main__":
    transfer(sys.argv[1])