szymon_dybczak
Esteemed Contributor III

So your approach is correct. NAT gateway will provide stable egrees IP address and that address could be whitelisted in SFTP server. But remember to route outbound traffic from databricks subnets to that NAT Gateway using i.e User-Defined Routes.
When you wrote: "Btw, it doesn't work". You mean that following script didn't work?

import requests
requests.get("https://api.ipify.org").text


If above script returned public IP address of your NAT Gateway then I have another thing to check. I had weird issues in the past with paramiko. Could you check if you are able to connect with pysftp?

1. First install library

pip install pysftp

2. Try to connect

import pysftp

hostname = 'your_hostname'
username = 'your_username'
password = 'your_password'

cnopts = pysftp.CnOpts()
cnopts.hostkeys = None

try:
    with pysftp.Connection(host=hostname, username=username, password=password, cnopts=cnopts)  as sftp:
        print("SFTP connection successful")
except Exception as e:
    print("SFTP connection failed: ", str(e))