Docs · Clients

Python Paramiko SFTP upload example

Paramiko is the standard SSH and SFTP library for Python. Many examples use AutoAddPolicy, which trusts any server; this one loads the published keys and rejects anything else.

These steps use the SFTP Harbor endpoint data.sftpharbor.com and the example login yourserver.alice: your server's name, a dot, and the user name. Signed-in customers see the same steps with their own login on the dashboard's overview.

Save the host keys next to the script as harbor_known_hosts. RejectPolicy refuses any key not in that file.

harbor_known_hosts
data.sftpharbor.com ssh-ed25519 …
upload.py
import paramiko

client = paramiko.SSHClient()
client.load_host_keys("harbor_known_hosts")
client.set_missing_host_key_policy(paramiko.RejectPolicy())
client.connect(
    "data.sftpharbor.com",
    port=22,
    username="yourserver.alice",
    key_filename="id_ed25519",
    look_for_keys=False,
    allow_agent=False,
)
sftp = client.open_sftp()
sftp.put("report.csv", "/report.csv")
client.close()

Host keys are also listed on the security page, with SSHFP records. When keys are rotated, the new ones are announced 30 days ahead and included above.