Skip to content

Commit f9271e9

Browse files
committed
fix(pgw): add updated bastion and allowed ips feature
1 parent 2306374 commit f9271e9

File tree

6 files changed

+84
-16
lines changed

6 files changed

+84
-16
lines changed

pages/public-gateways/concepts.mdx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ categories:
1212
- network
1313
---
1414

15+
## Allowed IPs
16+
17+
Allowed IPs is a feature of [SSH bastion](#ssh-bastion). It allows you to specify a list of IP address ranges which should be allowed to connect to the SSH bastion and the resources behind it. All other IP address will be blocked from connecting. Find out more in the [SSH bastion](/network/public-gateways/how-to/use-ssh-bastion/#how-to-configure-allowed-ips) documentation.
18+
1519
## Default route
1620

1721
The Public Gateway can advertise a default route to resources on an attached Private Network, which takes effect when the IP destination address for a packet is not known on the network itself. In effect, resources in a Private Network will know to route packets through the Public Gateway if the destination IP address is not a host on the Private Network itself.
@@ -113,7 +117,7 @@ See [IP mobility](#ip-mobility).
113117

114118
## SSH bastion
115119

116-
[SSH bastion](/public-gateways/how-to/use-ssh-bastion/) is a server dedicated to managing connections to the infrastructure behind your Public Gateway. When you activate SSH bastion on your Public Gateway, all the SSH keys held in your Project credentials are imported to the SSH bastion, providing a single point of entry. This makes management of your infrastructure easier and more secure.
120+
[SSH bastion](/public-gateways/how-to/use-ssh-bastion/) is a server dedicated to managing connections to the infrastructure behind your Public Gateway. When you activate SSH bastion on your Public Gateway, all the SSH keys held in your Project credentials are imported to the SSH bastion, providing a single point of entry. This makes management of your infrastructure easier and more secure. The [Allowed IPs](#allowed-ips) feature lets you control which public IP addresses can connect to the resources behind your bastion.
117121

118122
## Tags
119123

-14.1 KB
Loading
8.54 KB
Loading
170 Bytes
Loading
11 KB
Loading

pages/public-gateways/how-to/use-ssh-bastion.mdx

Lines changed: 79 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ categories:
1313
- network
1414
---
1515

16-
SSH bastion is a server dedicated to managing connections to the infrastructure behind your Public Gateway. When you activate SSH bastion on your Public Gateway, all [SSH keys held in your Project](https://console.scaleway.com/project/ssh-keys/) are imported to the SSH bastion, providing a single point of entry. You can then connect to resources behind the bastion (connected to the same Private Network as the Public Gateway) via the bastion. This makes management of your infrastructure easier and more secure, as you do not need to expose your other resources to the internet in order to connect to them, neither do you need to upload SSH keys to individual resources.
16+
SSH bastion is a server dedicated to managing connections to the infrastructure behind your Public Gateway. When you activate SSH bastion on your Public Gateway, all [SSH keys held in your Project](https://console.scaleway.com/project/ssh-keys/) are imported to the SSH bastion, providing a single point of entry. You can then connect to resources connected to the same Private Network as the Public Gateway, via the bastion. This makes management of your infrastructure easier and more secure, as you do not need to expose your other resources to the internet in order to connect to them, neither do you need to upload SSH keys to individual resources.
17+
18+
The [Allowed IPs](#how-to-configure-allowed-ips) feature lets you control which public IPs can access resources behind the bastion.
1719

1820
<Macro id="requirements" />
1921

@@ -27,23 +29,57 @@ SSH bastion is a server dedicated to managing connections to the infrastructure
2729
1. Click **Public Gateways** in the **Network** section of the Scaleway console side menu.
2830
2. Click the Public Gateway for which you want to activate SSH bastion. You are taken to the **Overview** page for that Public Gateway.
2931
<Lightbox src="scaleway-ssh-bastion-activate.webp" alt="" />
30-
3. Under **SSH Bastion** click the **Activate** button. A pop-up displays:
32+
3. Under **SSH Bastion**, use the toggle <Icon name="toggle"/> to activate the feature. A pop-up displays:
3133
<Lightbox src="scaleway-activate-ssh-bastion-popup.webp" alt="" />
3234
4. Enter the port that you want your SSH bastion to listen on (or leave the default port in place).
3335
<Message type="tip">
34-
The default port is 61000. When setting your own port, you must choose a port number between 1024 and 59999. The port that the SSH bastion listens on must not be a port already in use by a [NAT rule](/public-gateways/concepts/#nat).
36+
The default port is 61000 (ours), to avoid conflicts. When setting your own port, you must choose a port number between 1024 and 59999. The port that the SSH bastion listens on must not be a port already in use by a [NAT rule](/public-gateways/concepts/#nat).
3537
</Message>
3638
5. Copy the command to connect to a resource, and click **Save SSH bastion settings**.
3739

38-
You are redirected to your Public Gateway's **Overview** page, where SSH bastion is now activated. All the SSH keys in your [Project credentials](/iam/concepts/#api-key) at the time of activation are copied to the SSH bastion.
40+
You are redirected to your Public Gateway's **Overview** page, where SSH bastion is now activated. All the SSH keys in your [Project](/identity-and-access-management/organizations-and-projects/concepts/#project) at the time of activation are copied to the SSH bastion.
41+
42+
## How to configure allowed IPs
43+
44+
The [Allowed IPs](#how-to-configure-allowed-ips) feature lets you control which public IPs can connect to resources behind the bastion. All IPs are blocked except those specified in your Allowed IPs list.
45+
46+
When you first activate SSH bastion, the Allowed IPs list has one entry: a default IP range of `0.0.0.0/0` which gives access to **all** public IPs.
47+
48+
<Lightbox src="scaleway-ssh-bastion-allowed-ips.webp" alt="The Public Gateway's dashboard in the Scaleway console shows that SSH bastion is activated, and the Allowed IPs list contains one entry: 0.0.0.0/0" />
49+
50+
### How to allow all IPs
51+
52+
If you do **not** want to restrict connections to the resources behind the bastion to specific public IPs only, ***leave the default entry of `0.0.0.0/0` in place**. This IP range encompasses all possible public IPs, so will allow any public IP address to connect to the bastion (as long as they have a valid SSH key). No further configuration is required.
53+
54+
If you have deleted the default entry, you can re-add an entry for `0.0.0.0/0` at any time. Click the **Add allowed IPs** button, and add a single entry for `0.0.0.0/0` to restore access to all public IPs.
55+
56+
### How to restrict access to certain IPs
57+
58+
To restrict connections to resources behind the bastion to specific public IPs only, you must delete the default `0.0.0.0/0` entry, and add entries for the specific IP ranges that you want to allow. Follow the steps below
59+
60+
1. Ensure you have [activated SSH bastion](#how-to-activate-ssh-bation).
61+
2. In the **Allowed IPs** list, delete the default IP range entry `0.0.0.0/0` by clicking the <Icon name="delete"/> button next to it.
62+
A pop-up displays, asking you to confirm that you want to delete this IP range.
63+
3. Type **DELETE** in the box, then click **Delete allowed IP range**.
64+
The IP range is deleted and you are returned to the Allowed IPs list.
65+
4. Click the **+ Add allowed IPs** button.
66+
A pop-up displays, asking you to enter the IPv4 address ranges to allow.
67+
<Lightbox src="scaleway-add-allowed-ips.webp" alt="A pop-up screen from the Scaleway console, with a text box to allow the user to enter multiple IPv4 ranges separated by newlines. The instructions say: Add one or more IPv4 address ranges to allow. Always include the subnet mask. Use a tool like ipcalc if you need help calculating the subnet of your IP ranges." />
68+
5. Enter the IPv4 address ranges you to want to allow to connect to your SSH bastion. In each case, include the subnet mask (use `/32` for single addresses). You can add multiple IP ranges in one go by separating them with new lines.
69+
6. Click the **Add IPs** button.
70+
The IPs are added, and you are returned to the Allowed IPs list.
71+
72+
Repeat steps 4 - 6 to add more IP range entries, if you wish.
73+
74+
You can delete an entry from the list at any time by clicking the <Icon name="delete" /> button next to it.
3975

4076
## How to reimport SSH keys
4177

42-
If you add new SSH keys to your [Project credentials](/iam/concepts/#api-key) after activating SSH bastion, you will need to perform a reimport to update the bastion with the new keys.
78+
If you add new SSH keys to your [Project](/identity-and-access-management/organizations-and-projects/concepts/#project) after activating SSH bastion, you will need to perform a reimport to update the bastion with the new keys.
4379

4480
1. Click **Public Gateways** in the **Network** section of the Scaleway console side menu.
4581
2. Click the Public Gateway for which you want to update the SSH bastion. You are taken to the **Overview** page for that Public Gateway.
46-
3. Under **SSH Bastion** click the **Reimport SSH keys** button.
82+
3. Under **SSH Bastion** click the **Reimport list** button.
4783
<Lightbox src="scaleway-ssh-bastion-reimport.webp" alt="" />
4884

4985
Your SSH bastion is updated with the new SSH keys.
@@ -60,18 +96,40 @@ You can connect to a resource behind the bastion using its private IP address on
6096

6197
### How to connect using the resource's fully-qualified domain name (FQDN)
6298

99+
<<<<<<< HEAD
63100
The domain to use is set when the Public Gateway is attached to the Private Network. Therefore, the FQDN to use depends on how you made this attachment:
64101

65102
- **Via the Scaleway console**: The FQDN takes the form `resource-name.priv`
66103
- **Via Terraform/OpenTofu**: The FQDN takes the form `resource-name.dns_local_name` where `dns_local_name` is [this](https://registry.terraform.io/providers/scaleway/scaleway/latest/docs/resources/vpc_public_gateway_dhcp#dns_local_name) Terraform/OpenTofu option.
67104
- **Via the Scaleway CLI or API**: The FQDN takes the form `resource-name.dns_local_name` where `dns_local_name` follows the specification [here](https://www.scaleway.com/en/developers/api/public-gateway/#path-dhcp-create-a-dhcp-configuration), defaulting to `.priv`.
68105

69106
Carry out the following command on your terminal to connect to a resource inside your Private Network. Remember to replace `FQDN` with the FQDN in the format specified above.
107+
=======
108+
The command to use is:
109+
>>>>>>> 9fff0a96e (fix(pgw): add updated bastion and allowed ips feature)
70110

71111
```bash
72112
ssh -J bastion@PUBLIC_IP_OF_PUBLIC_GATEWAY:61000 user@FQDN
73113
```
74114

115+
The FQDN is `<resource-name>.<private-network-name>.internal`.
116+
117+
When connecting as the user `alex` on an Instance named `scw-frosty-cannon` on a Private Network named `pvn-silly-goodall`, where the Public Gateway has an IP `51.158.125.88` and SSH bastion is configured on port 6100, the full connection command would therefore be:
118+
119+
```bash
120+
121+
```
122+
123+
<Message type="note">
124+
125+
For [Legacy Private Networks](/network/public-gateways/concepts/#ipam) not in IPAM mode and still using DHCP configuration objects, the FQDN may be different. The domain to use was set when the Public Gateway was attached to the Private Network. Therefore, the FQDN to use depends on how you made this attachment:
126+
127+
- **Via the Scaleway console**: The FQDN takes the form `resource-name.priv`
128+
- **Via Terraform**: The FQDN takes the form `resource-name.dns_local_name` where `dns_local_name` is [this](https://registry.terraform.io/providers/scaleway/scaleway/latest/docs/resources/vpc_public_gateway_dhcp#dns_local_name) Terraform option.
129+
- **Via the Scaleway CLI or API**: The FQDN takes the form `resource-name.dns_local_name` where `dns_local_name` follows the specification [here](https://www.scaleway.com/en/developers/api/public-gateway/#path-dhcp-create-a-dhcp-configuration), defaulting to `.priv`.
130+
131+
</Message>
132+
75133
### How to edit your SSH configuration files for connection
76134

77135
Carry out the following steps to avoid the need to repeat `-J bastion@<public-IP-of-gateway>:61000` in your SSH connection commands. The following steps must be repeated on all local machines that want to connect to a resource behind the SSH bastion in this way.
@@ -81,12 +139,12 @@ Carry out the following steps to avoid the need to repeat `-J bastion@<public-IP
81139
nano ~/.ssh/config
82140
```
83141
Paste the following code into the file, then save and exit. Ensure that you make the following replacements:
84-
- `.priv`: If you attached the Public Gateway to the Private Network via the console, this is the correct value. However, if you used another method such as Terraform/OpenTofu, API, or CLI you may need to replace this value - see [above](#how-to-connect-using-the-resources-fully-qualified-domain-name-fqdn).
142+
- `.<private-network-name>`: If your Public Gateway is in IPAM mode, this is the correct value. However, if you have a legacy gateway, you may need to replace this value with `.priv` or `<dns_local_name>` - see [above](#how-to-connect-using-the-resource's-fully-qualified-domain-name-(fqdn)).
85143
- `PUBLIC_IP_OF_PUBLIC_GATEWAY`: The public IP address of your gateway
86144
- `SSH_BASTION_PORT`: The port you set when activating SSH bastion on your gateway
87145

88146
```bash
89-
Host *.priv
147+
Host *.<private-network-name>
90148
ProxyJump bastion@PUBLIC_IP_OF_PUBLIC_GATEWAY:SSH_BASTION_PORT
91149
```
92150
2. Alternatively, to configure at system-wide level, open your system-wide configuration file on your local machine with a text-editor such as `nano`:
@@ -100,14 +158,20 @@ Carry out the following steps to avoid the need to repeat `-J bastion@<public-IP
100158
ssh FQDN
101159
```
102160

103-
## How to edit or deactivate SSH bastion
161+
## How to edit the SSH bastion port
104162

105163
1. Click **Public Gateways** in the **Network** section of the Scaleway console side menu.
106-
2. Click the Public Gateway for which you want to edit or deactivate SSH bastion. You are taken to the **Overview** page for that Public Gateway.
107-
3. Under **SSH Bastion** click the "edit" icon (<Icon name="edit" />) **Edit** button. A pop-up displays.
108-
4. Edit your SSH bastion as required. You can make the following edits:
109-
- Use the <Icon name="toggle" /> toggle to disable SSH bastion.
110-
- Change the port on which your SSH bastion listens.
111-
5. Click **Save settings**.
164+
2. Click the Public Gateway you want to edit SSH bastion for. You are taken to the **Overview** page for that Public Gateway.
165+
3. Under **SSH Bastion** click **Edit**, next to the port number. A pop-up displays.
166+
4. Edit your SSH bastion port as required.
167+
5. Click **Save**.
112168

113169
Your edits are saved, and you are redirected to your Public Gateway's **Overview** page.
170+
171+
## How to deactivate SSH bastion
172+
173+
1. Click **Public Gateways** in the **Network** section of the Scaleway console side menu.
174+
2. Click the Public Gateway you want to deactivate SSH bastion on. You are taken to the **Overview** page for that Public Gateway.
175+
3. Under **SSH Bastion** use the toggle <Icon name="toggle"/> to deactivate the bastion.
176+
177+
SSH bastion is deactivated on this gateway. You can reactivate it at any time.

0 commit comments

Comments
 (0)