> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stackshift.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# SSH and forwarded ports

> Log in over the shared IPv4 on the server’s SSH port or over IPv6 on port 22, and forward up to 10 more TCP or UDP ports on the shared IPv4.

## Goal

Connect over SSH from any network and reach non-web services over IPv4.

## Prerequisites

* A running VPS and the private key that matches the public key you gave at order time.

## Workflow

**Step 1**

Open the server, then Networking. The SSH row shows the command with the server’s SSH port.

**Step 2**

Run it, for example ssh -p 24817 [root@myserver.compute.stackshift.cloud](mailto:root@myserver.compute.stackshift.cloud). From a network with IPv6 you can also run ssh root@\<IPv6 address> on port 22.

**Step 3**

To limit who can try to connect, choose Only allow some addresses and list IP addresses or ranges.

**Step 4**

For another service, open Forwarded ports, pick TCP or UDP, enter the port on the server and choose Forward port.

## The SSH port

* Each new VPS gets one SSH port on the shared IPv4, picked from 20000 to 39999 when the server is created. It forwards to port 22 on the server.
* The port works with SFTP, rsync, scp, Ansible, CI deploy steps and remote managers such as Coolify. Each of them accepts a custom port.
* Your client’s real IP address reaches the server, so fail2ban, sshd logs and AllowUsers rules see the real source.
* Anyone can try to connect until you set Only allow these addresses. Enter addresses or ranges such as 102.89.34.17, 197.210.8.0/24, up to 20. Leave it empty to allow everyone. The limit applies to the shared IPv4 port; on IPv6 use the server’s own firewall.

## Forwarded ports

* Forward up to 10 ports per VPS, not counting SSH. StackShift picks the public port from 20000 to 39999, and the row shows \<shared IPv4>:\<public port> → port \<n> · TCP or UDP.
* The visitor’s IP is kept. Each forward can have its own Only allow list.
* Use Edit to change a forward’s allowed addresses and Stop forwarding to remove it. The change applies within about 15 seconds.
* Port 22 is already forwarded as SSH. A forward to port 25 stays closed unless a mail request is approved.
* Every port is already open on IPv6, so IPv6 clients connect to the real port directly.
* One VPS cannot reach another VPS through the shared IPv4 and a forwarded port. Use IPv6 between servers.

## When a forwarded port is not enough

Clients that can only use a well-known port on IPv4, such as 5432 for PostgreSQL or 51820 for WireGuard, need a dedicated IPv4. With one attached, every port on that address goes straight to the server.

## Expected result

> [!TIP]
>
> SSH works over both IPv4 and IPv6, and each forwarded port answers on \<shared IPv4>:\<public port>.

## Common failures

> [!WARNING]
>
> * Connection timed out: check the port shown in the SSH row, that the server is running, and that your current IP is in Only allow these addresses if you set it.
> * Permission denied (publickey): the connection reached the server. Use the login user shown and the private key that matches a key in that user’s authorized\_keys.
> * The forwarded port refuses connections: check the service listens on all addresses (0.0.0.0 or ::), not only 127.0.0.1, and that the server’s own firewall allows it.

## Related guides

> [card] [How a VPS is reached](https://docs.stackshift.cloud/compute/networking-overview.md)
>
> Every VPS gets its own public IPv6, a name under compute.stackshift.cloud, websites and SSH over a shared IPv4, and outbound IPv4. A dedicated IPv4 is an optional add-on.

> [card] [Dedicated IPv4 add-on](https://docs.stackshift.cloud/compute/dedicated-ipv4.md)
>
> Attach an IPv4 address that only your VPS uses, for a fixed IP partners can allow-list, well-known ports on IPv4, or a mail server.

> [card] [Troubleshoot VPS networking](https://docs.stackshift.cloud/compute/troubleshooting.md)
>
> Match the symptom to the right check: SSH port, allowed addresses, DNS records, certificate status, the app port or the PROXY protocol.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.