<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Using SFTP connector with private/public keys in Pipelines</title>
    <link>https://community.fabric.microsoft.com/t5/Pipelines/Using-SFTP-connector-with-private-public-keys/m-p/4903075#M8907</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="719515" data-lia-user-login="pmscorca" class="lia-mention lia-mention-user"&gt;pmscorca&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you can see from the idea status, the ability to connect to SFTP using a SSH key is planned to be developed. In the meantime you could use a notebook to get the data from the SFTP server.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try the code below to connect to a SFTP server using paramiko library. Add your private key content to a key vault secret.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;from paramiko import SSHClient, AutoAddPolicy, RSAKey
from io import StringIO

# Configuration
SFTP_HOST = "&amp;lt;sftp-server&amp;gt;"
SFTP_PORT = 22
SFTP_USERNAME = "&amp;lt;your-username&amp;gt;"
KEY_VAULT_NAME = "&amp;lt;your-keyvault-name&amp;gt;"
PRIVATE_KEY_SECRET_NAME = "&amp;lt;sftp-private-key&amp;gt;"
REMOTE_DIRECTORY = "&amp;lt;/sftp/folder_with_files&amp;gt;"
LAKEHOUSE_FOLDER = "Files/sftp_documents"
LAKEHOUSE_PATH = "/lakehouse/default"

# Retrieve private key from Key Vault
private_key_content = notebookutils.credentials.getSecret(KEY_VAULT_NAME, PRIVATE_KEY_SECRET_NAME)

# Create lakehouse folder if not exists
notebookutils.fs.mkdirs(LAKEHOUSE_FOLDER)

# Create SSH client
ssh_client = SSHClient()
ssh_client.set_missing_host_key_policy(AutoAddPolicy())

try:
    # Connect using private key from memory
    pkey = RSAKey.from_private_key(StringIO(private_key_content))
    ssh_client.connect(
        hostname=SFTP_HOST,
        port=SFTP_PORT,
        username=SFTP_USERNAME,
        pkey=pkey,
        look_for_keys=False,
        allow_agent=False
    )
    
    # Download file to Lakehouse path
    sftp_client = ssh_client.open_sftp()
    
    # List all files in directory
    print(f"Listing files in {REMOTE_DIRECTORY}:")
    file_attrs = sftp_client.listdir_attr(REMOTE_DIRECTORY)
    
    files_to_download = []
    for attr in file_attrs:
        # Skip directories, only process files
        if not (attr.st_mode &amp;amp; 0o040000):  # Not a directory
            files_to_download.append(attr.filename)
            print(f"  - {attr.filename} ({attr.st_size} bytes)")
    
    #print(f"\nFound {len(files_to_download)} file(s) to download")
    
    # Download all files directly to Lakehouse
    downloaded_count = 0
    for filename in files_to_download:
        remote_file_path = f"{REMOTE_DIRECTORY}/{filename}"
        lakehouse_file_path = f"{LAKEHOUSE_PATH}/{LAKEHOUSE_FOLDER}/{filename}"
        
        try:
            # Download directly to Lakehouse
            sftp_client.get(remote_file_path, lakehouse_file_path)
            print(f"Downloaded: {filename} -&amp;gt; {lakehouse_file_path}")
            
            downloaded_count += 1
        except Exception as e:
            print(f"Error downloading {filename}: {str(e)}")
    
    print(f"\nSuccessfully downloaded {downloaded_count}/{len(files_to_download)} file(s)")
  
finally:
    ssh_client.close()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps. If so, please give kudos &lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt; and mark as Accepted Solution &lt;span class="lia-unicode-emoji" title=":heavy_check_mark:"&gt;✔️&lt;/span&gt; to help others.&lt;/P&gt;</description>
    <pubDate>Tue, 16 Dec 2025 12:24:46 GMT</pubDate>
    <dc:creator>nielsvdc</dc:creator>
    <dc:date>2025-12-16T12:24:46Z</dc:date>
    <item>
      <title>Using SFTP connector with private/public keys</title>
      <link>https://community.fabric.microsoft.com/t5/Pipelines/Using-SFTP-connector-with-private-public-keys/m-p/4902893#M8901</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I need to implement a pipeline to get some files from an SFTP folder, by using the related Fabric connector that but it doesn't support the authentication by private/public keys.&lt;/P&gt;&lt;P&gt;I've noticed there is this idea:&amp;nbsp;&lt;A href="https://community.fabric.microsoft.com/t5/Fabric-Ideas/SSH-Support-for-SFTP-Connection/idc-p/4894558#M165459" target="_self"&gt;SSH Support for SFTP Connection&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does it exist any alternative and easy solution, please? Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 16 Dec 2025 08:10:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Pipelines/Using-SFTP-connector-with-private-public-keys/m-p/4902893#M8901</guid>
      <dc:creator>pmscorca</dc:creator>
      <dc:date>2025-12-16T08:10:58Z</dc:date>
    </item>
    <item>
      <title>Re: Using SFTP connector with private/public keys</title>
      <link>https://community.fabric.microsoft.com/t5/Pipelines/Using-SFTP-connector-with-private-public-keys/m-p/4903075#M8907</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="719515" data-lia-user-login="pmscorca" class="lia-mention lia-mention-user"&gt;pmscorca&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you can see from the idea status, the ability to connect to SFTP using a SSH key is planned to be developed. In the meantime you could use a notebook to get the data from the SFTP server.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try the code below to connect to a SFTP server using paramiko library. Add your private key content to a key vault secret.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;from paramiko import SSHClient, AutoAddPolicy, RSAKey
from io import StringIO

# Configuration
SFTP_HOST = "&amp;lt;sftp-server&amp;gt;"
SFTP_PORT = 22
SFTP_USERNAME = "&amp;lt;your-username&amp;gt;"
KEY_VAULT_NAME = "&amp;lt;your-keyvault-name&amp;gt;"
PRIVATE_KEY_SECRET_NAME = "&amp;lt;sftp-private-key&amp;gt;"
REMOTE_DIRECTORY = "&amp;lt;/sftp/folder_with_files&amp;gt;"
LAKEHOUSE_FOLDER = "Files/sftp_documents"
LAKEHOUSE_PATH = "/lakehouse/default"

# Retrieve private key from Key Vault
private_key_content = notebookutils.credentials.getSecret(KEY_VAULT_NAME, PRIVATE_KEY_SECRET_NAME)

# Create lakehouse folder if not exists
notebookutils.fs.mkdirs(LAKEHOUSE_FOLDER)

# Create SSH client
ssh_client = SSHClient()
ssh_client.set_missing_host_key_policy(AutoAddPolicy())

try:
    # Connect using private key from memory
    pkey = RSAKey.from_private_key(StringIO(private_key_content))
    ssh_client.connect(
        hostname=SFTP_HOST,
        port=SFTP_PORT,
        username=SFTP_USERNAME,
        pkey=pkey,
        look_for_keys=False,
        allow_agent=False
    )
    
    # Download file to Lakehouse path
    sftp_client = ssh_client.open_sftp()
    
    # List all files in directory
    print(f"Listing files in {REMOTE_DIRECTORY}:")
    file_attrs = sftp_client.listdir_attr(REMOTE_DIRECTORY)
    
    files_to_download = []
    for attr in file_attrs:
        # Skip directories, only process files
        if not (attr.st_mode &amp;amp; 0o040000):  # Not a directory
            files_to_download.append(attr.filename)
            print(f"  - {attr.filename} ({attr.st_size} bytes)")
    
    #print(f"\nFound {len(files_to_download)} file(s) to download")
    
    # Download all files directly to Lakehouse
    downloaded_count = 0
    for filename in files_to_download:
        remote_file_path = f"{REMOTE_DIRECTORY}/{filename}"
        lakehouse_file_path = f"{LAKEHOUSE_PATH}/{LAKEHOUSE_FOLDER}/{filename}"
        
        try:
            # Download directly to Lakehouse
            sftp_client.get(remote_file_path, lakehouse_file_path)
            print(f"Downloaded: {filename} -&amp;gt; {lakehouse_file_path}")
            
            downloaded_count += 1
        except Exception as e:
            print(f"Error downloading {filename}: {str(e)}")
    
    print(f"\nSuccessfully downloaded {downloaded_count}/{len(files_to_download)} file(s)")
  
finally:
    ssh_client.close()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps. If so, please give kudos &lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt; and mark as Accepted Solution &lt;span class="lia-unicode-emoji" title=":heavy_check_mark:"&gt;✔️&lt;/span&gt; to help others.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Dec 2025 12:24:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Pipelines/Using-SFTP-connector-with-private-public-keys/m-p/4903075#M8907</guid>
      <dc:creator>nielsvdc</dc:creator>
      <dc:date>2025-12-16T12:24:46Z</dc:date>
    </item>
    <item>
      <title>Re: Using SFTP connector with private/public keys</title>
      <link>https://community.fabric.microsoft.com/t5/Pipelines/Using-SFTP-connector-with-private-public-keys/m-p/4903186#M8911</link>
      <description>&lt;P&gt;Hi, thanks for your reply.&lt;/P&gt;&lt;P&gt;However I hope that a such feature will be released as soon as possible. Azure Data Factory has it!&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 16 Dec 2025 15:08:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Pipelines/Using-SFTP-connector-with-private-public-keys/m-p/4903186#M8911</guid>
      <dc:creator>pmscorca</dc:creator>
      <dc:date>2025-12-16T15:08:14Z</dc:date>
    </item>
    <item>
      <title>Re: Using SFTP connector with private/public keys</title>
      <link>https://community.fabric.microsoft.com/t5/Pipelines/Using-SFTP-connector-with-private-public-keys/m-p/5145946#M9299</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="290706" data-lia-user-login="nielsvdc" class="lia-mention lia-mention-user"&gt;nielsvdc&lt;/a&gt;&amp;nbsp;, how did you handle Notebook IP whitelisting at SFTP Server side?&lt;/P&gt;</description>
      <pubDate>Thu, 09 Apr 2026 13:46:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Pipelines/Using-SFTP-connector-with-private-public-keys/m-p/5145946#M9299</guid>
      <dc:creator>PrachiJain_2025</dc:creator>
      <dc:date>2026-04-09T13:46:27Z</dc:date>
    </item>
    <item>
      <title>Re: Using SFTP connector with private/public keys</title>
      <link>https://community.fabric.microsoft.com/t5/Pipelines/Using-SFTP-connector-with-private-public-keys/m-p/5148134#M9321</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="791098" data-lia-user-login="PrachiJain_2025" class="lia-mention lia-mention-user"&gt;PrachiJain_2025&lt;/a&gt;, unfortunately you cannot do whitelisting when using fabric notebooks. With pipelines you would normally use a gateway for this, but this is not supported for notebooks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Optionally, you could use an Azure Logic App – which does support authentication with keys – to do the SFTP stuff. But you need to configure the Logic App to use a NAT gateway for this. Check this article for:&amp;nbsp;&lt;A href="https://techcommunity.microsoft.com/blog/integrationsonazureblog/static-ip-of-logic-app-standard-using-nat-gateway/3721443" target="_blank"&gt;Static IP of Logic App Standard using NAT Gateway | Microsoft Community Hub&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;After you configured the Logic App, you can use the Logic App's webhook to call it from a Fabric pipeline or via code using a notebook.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps. If so, please give kudos &lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2026 07:44:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Pipelines/Using-SFTP-connector-with-private-public-keys/m-p/5148134#M9321</guid>
      <dc:creator>nielsvdc</dc:creator>
      <dc:date>2026-04-14T07:44:55Z</dc:date>
    </item>
  </channel>
</rss>

