Skip to content

Commit 786e3c5

Browse files
RoRoJjcirinosclwynerda-codes
authored
fix(pgw): add updated bastion and allowed ips feature (#4060)
* fix(pgw): add updated bastion and allowed ips feature * Apply suggestions from code review Co-authored-by: Jessica <[email protected]> Co-authored-by: nerda-codes <[email protected]> * fix(pgw): finish wlloed ips feature * fix(various): fix unwanted files * fix(pgw): remove asterisk * fix(pgw): unwanted files * fix(pgw): add message --------- Co-authored-by: Jessica <[email protected]> Co-authored-by: nerda-codes <[email protected]>
1 parent 3dc32ba commit 786e3c5

File tree

8 files changed

+90
-25
lines changed

8 files changed

+90
-25
lines changed

pages/public-gateways/concepts.mdx

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

15+
## Allowed IPs
16+
17+
The Allowed IPs feature is only available to [IPAM-mode](#ipam) Public Gateways. Legacy gateways are not compatible with this feature.
18+
</Message>
19+
20+
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 addresses will be blocked from connecting. Find out more in the [SSH bastion](/public-gateways/how-to/use-ssh-bastion/#how-to-configure-allowed-ips) documentation.
21+
1522
## Default route
1623

1724
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 +120,7 @@ See [IP mobility](#ip-mobility).
113120

114121
## SSH bastion
115122

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.
123+
[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.
117124

118125
## Tags
119126

6.23 KB
Loading
8.54 KB
Loading
26.6 KB
Loading
42.3 KB
Loading
20.3 KB
Loading

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

Lines changed: 79 additions & 21 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,61 @@ 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**, click **Enable SSH bastion** 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](/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+
<Message type="note">
45+
The Allowed IPs feature is only available to [IPAM-mode](/public-gateways/concepts/#ipam) Public Gateways. Legacy gateways are not compatible with this feature.
46+
</Message>
47+
48+
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.
49+
50+
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.
51+
52+
<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" />
53+
54+
### How to allow all IPs
55+
56+
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.
57+
58+
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.
59+
60+
### How to restrict access to certain IPs
61+
62+
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:
63+
64+
1. Ensure you have [activated SSH bastion](#how-to-activate-ssh-bation).
65+
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.
66+
A pop-up displays, asking you to confirm that you want to delete this IP range.
67+
3. Type **DELETE** in the box, then click **Delete allowed IP range**.
68+
The IP range is deleted and you are returned to the Allowed IPs list.
69+
4. Click the **+ Add allowed IPs** button.
70+
A pop-up displays, asking you to enter the IPv4 address ranges to allow.
71+
<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." />
72+
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.
73+
6. Click the **Add IPs** button.
74+
The IPs are added, and you are returned to the Allowed IPs list.
75+
76+
Repeat steps 4 - 6 to add more IP range entries, if you wish.
77+
78+
You can delete an entry from the list at any time by clicking the <Icon name="delete" /> button next to it.
3979

4080
## How to reimport SSH keys
4181

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.
82+
If you add new SSH keys to your [Project](/organizations-and-projects/concepts/#project) after activating SSH bastion, you will need to perform a reimport to update the bastion with the new keys.
4383

4484
1. Click **Public Gateways** in the **Network** section of the Scaleway console side menu.
4585
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.
86+
3. Under **SSH Bastion** click the **Reimport list** button.
4787
<Lightbox src="scaleway-ssh-bastion-reimport.webp" alt="" />
4888

4989
Your SSH bastion is updated with the new SSH keys.
@@ -60,18 +100,30 @@ You can connect to a resource behind the bastion using its private IP address on
60100

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

63-
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:
103+
The command to use is:
64104

65-
- **Via the Scaleway console**: The FQDN takes the form `resource-name.priv`
66-
- **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.
67-
- **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`.
105+
```bash
106+
ssh -J bastion@PUBLIC_IP_OF_PUBLIC_GATEWAY:61000 user@FQDN
107+
```
108+
q
109+
The FQDN is `<resource-name>.<private-network-name>.internal`.
68110

69-
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.
111+
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:
70112

71113
```bash
72-
ssh -J bastion@PUBLIC_IP_OF_PUBLIC_GATEWAY:61000 user@FQDN
114+
ssh -J bastion@51.158.125:61000 [email protected]
73115
```
74116

117+
<Message type="note">
118+
119+
For [Legacy Private Networks](/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:
120+
121+
- **Via the Scaleway console**: The FQDN takes the form `resource-name.priv`
122+
- **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.
123+
- **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`.
124+
125+
</Message>
126+
75127
### How to edit your SSH configuration files for connection
76128

77129
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 +133,12 @@ Carry out the following steps to avoid the need to repeat `-J bastion@<public-IP
81133
nano ~/.ssh/config
82134
```
83135
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).
136+
- `.<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-resources-fully-qualified-domain-name-fqdn).
85137
- `PUBLIC_IP_OF_PUBLIC_GATEWAY`: The public IP address of your gateway
86138
- `SSH_BASTION_PORT`: The port you set when activating SSH bastion on your gateway
87139

88140
```bash
89-
Host *.priv
141+
Host *.<private-network-name>
90142
ProxyJump bastion@PUBLIC_IP_OF_PUBLIC_GATEWAY:SSH_BASTION_PORT
91143
```
92144
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 +152,20 @@ Carry out the following steps to avoid the need to repeat `-J bastion@<public-IP
100152
ssh FQDN
101153
```
102154

103-
## How to edit or deactivate SSH bastion
155+
## How to edit the SSH bastion port
104156

105157
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**.
158+
2. Click the Public Gateway you want to edit SSH bastion for. You are taken to the **Overview** page for that Public Gateway.
159+
3. Under **SSH Bastion** click **Edit**, next to the port number. A pop-up displays.
160+
4. Edit your SSH bastion port as required.
161+
5. Click **Save**.
112162

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

pages/public-gateways/quickstart.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ When you activate SSH bastion on your Public Gateway, all [SSH keys held in your
5757

5858
1. Click **Public Gateways** in the **Network** section of the Scaleway console side menu.
5959
2. Click the Public Gateway for which you want to activate SSH bastion. You are taken to the **Overview** page for that Public Gateway.
60-
3. Under **SSH Bastion**, click the **Activate** button. A pop-up displays.
60+
3. Under **SSH Bastion**, click **Enable SSH bastion**. A pop-up displays.
6161
4. Enter the port that you want your SSH bastion to listen on (or leave the default port in place).
6262
<Message type="tip">
6363
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).
6464
</Message>
65-
5. Copy the command to connect to a resource, and click **Save SSH bastion settings**.
65+
5. Copy the command to connect to a resource, and click **Activate**.
6666

67-
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. The command to use to connect to resources behind the bastion is displayed. See the [SSH bastion documentation](/public-gateways/how-to/use-ssh-bastion/) for further help.
67+
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. The command to use to connect to resources behind the bastion is displayed. See the [SSH bastion documentation](/public-gateways/how-to/use-ssh-bastion/) for further help, including information about restricting connections via the **Allowed IPs** feature.

0 commit comments

Comments
 (0)