SSH bastion is the recommended solution. For advanced users only, another manual workaround is to create a static NAT association between a port of your Public Gateway (e.g. 2222
) and the private IP assigned to your Instance, on the SSH port (22
by default). Then, SSH to the Public Gateway’s IP on port 2222
.
I cannot connect to my Instance using SSH after attaching it to a Private Network with a Public Gateway
If you are having trouble connecting to your Instance via SSH, when the Instance is attached to a Private Network which also has an attached Public Gateway, read on for help and solutions.
The action to take depends on whether:
- The Private Network(s) attached to your Instance have DHCP enabled, and
- Your Public Gateway is set to advertise a default route (true by default).
If the above two conditions are not true, there may be other factors impacting your Instance, like one of your Instances running a DHCP server. Try disconnecting and reconnecting the Instance from the Private Network.
If DHCP is activated and your Public Gateway is set to advertise a default route, not being able to connect to your Instance via SSH is expected behavior. All the traffic towards your Instance now goes through the Public Gateway.
To access your Instance using SSH in this scenario, the recommended solution is to use SSH bastion.