How to use SFTP with IPv6 Address in Linux? [SOLVED]


In the ever-expanding world of networking, the adoption of IPv6 addresses has become increasingly important for businesses and individuals alike. As we adapt to this next-generation protocol, understanding how to use essential tools, such as SFTP, in an IPv6 environment is crucial. This comprehensive guide will walk you through the process of how to use SFTP with IPv6 addresses in Linux, ensuring seamless and secure file transfers in the modern digital landscape. From configuring the SSH server to properly connecting with the IPv6 address, we will cover each step in detail, providing you with the knowledge and skills necessary to master SFTP in an IPv6-enabled world.


Get the IPv6 address for SFTP

It is important to make sure your SSH service is listening on IPv6 interface or else you will not be able to connect to the SSH server using SFTP.

To check if SSH is listening on the IPv6 interface, use the ss or netstat command:

Using ss:

$ ss -tuln | grep :22
tcp   LISTEN 0      128                 *          
tcp   LISTEN 0      128    [2001:db8:1234:0:b9a0:6553:347b:3022]:22            [::]:*       

Using netstat (if not installed by default, you can install it with sudo apt install net-tools on Debian-based systems or sudo yum install net-tools on RHEL-based systems):

$ netstat -ntlp | grep :22
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0*               LISTEN      -                   
tcp6       0      0 2001:db8:1234:0:b9a0:22 :::*                    LISTEN      -         

The output must contain a tcp6 entry listening on an IPv6 address(usually represented by :: or :::)


Use SFTP with IPv6 Address in Linux

To use SFTP with an IPv6 address, you'll need to follow the general syntax provided below. Each argument is explained to help you understand their purpose.


sftp -o "AddressFamily inet6" -P <port_number> <username>@<IPv6_address>


  • sftp: This is the command to initiate an SFTP session.
  • -o "AddressFamily inet6": This option tells SFTP to use the IPv6 addressing family for the connection.
  • -P <port_number>: This option specifies the port number on which the remote SFTP server is listening. Replace <port_number> with the actual port number. If the remote server uses the default SFTP port (22), you can omit this option.
  • <username>: Replace this with the username of the account on the remote server you want to connect to.
  • <IPv6_address>: Replace this with the actual IPv6 address of the remote server. Enclose the address in square brackets [ and ].

Here is an example:

$ sftp  -o "AddressFamily inet6" -P 22 user@[2a00:8a00:4000:45d::89]
Warning: Permanently added '2a00:8a00:4000:45d::89' (ECDSA) to the list of known hosts.
user@2a00:8a00:4000:45d::89's password:
Connected to 2a00:8a00:4000:45d::89.
sftp> pwd
Remote working directory: /

Explanation of the example:

  • sftp: Initiates an SFTP session.
  • -o "AddressFamily inet6": Specifies that the connection should use IPv6.
  • -P 22: Connects to the remote server on port 22, which is the default SFTP port. We could also omit this option for default port i.e. 22.
  • user: The username of the account on the remote server.
  • [2a00:8a00:4000:45d::89]: The IPv6 address of the remote server. The square brackets are necessary to properly parse the IPv6 address.



In summary, using SFTP with IPv6 addresses in Linux involves configuring the SSH server to listen on IPv6 interfaces, verifying the setup, and connecting to the server using the correct syntax. First, ensure that the SSH configuration file is set to listen on both IPv4 and IPv6 interfaces. Restart the SSH service and verify that it's listening on the IPv6 interface using the ss or netstat command. To initiate an SFTP session with an IPv6 address, use the syntax sftp -o "AddressFamily inet6" -P <port_number> <username>@<IPv6_address>. When connecting to the remote server, follow best practices such as using secure authentication methods, regularly updating software, restricting user access, implementing firewall rules, and monitoring server logs. Exercise caution when using options that disable strict host key checking or redirect the storage of known host keys, as these can increase security risks.


Further Reading

man page for sftp


Views: 281
Deepak Prasad

Deepak Prasad

He is the founder of GoLinuxCloud and brings over a decade of expertise in Linux, Python, Go, Laravel, DevOps, Kubernetes, Git, Shell scripting, OpenShift, AWS, Networking, and Security. With extensive experience, he excels in various domains, from development to DevOps, Networking, and Security, ensuring robust and efficient solutions for diverse projects. You can connect with him on his LinkedIn profile.

Can't find what you're searching for? Let us assist you.

Enter your query below, and we'll provide instant results tailored to your needs.

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can send mail to

Thank You for your support!!

Leave a Comment