SSH bastion access to services
Access namespace services like pods or databases for maintenance
You can add SSH bastion to an environment to allow team members to securely access resources in the environment, for example, to run utilities accessing backend services like database containers or to perform administrative commands like starting and stopping jobs on private containers not connected to the public internet.
Create bastion service
Navigate to the Application Template settings to create a bastion service that will run an SSH image. This example creates a service for you:
- name: bastion
image: binlab/bastion
command:
- sh
- "-c"
- >-
cp /var/lib/bastion/public-key /var/lib/bastion/authorized_keys &&
chmod 600 /var/lib/bastion/authorized_keys &&
chown bastion:bastion /var/lib/bastion/authorized_keys &&
bastion
ports:
- type: node_port
target_port: '22'
port: '22'
loadbalancer: true
hostname: bastion-${env_id}-${domain}Let's take a look at these configuration directives:
nameis the name of the service.imagerefers to binlab's public SSH container.commandprovides a series of bash commands that will be run to copy the keys from a known location (keys will be uploaded in the next step) and start the bastion service.portsspecifies that the service will listen on port22, which is standard for SSH.hostnamedescribes the hostname that will be generated for the bastion service.
Create and upload public keys to gain access
Next we'll use a just-in-time file mount to upload the public keys that will be used to access the bastion.
Create a text file on your computer called public-key with no file extension. Add the list of public SSH keys to this file, placing each key on a new line. An example file with two keys might look like this:
Now navigate to App Settings and scroll down to the "Just-in-time File Mounts" section. Upload the public-key file with the file directory /var/lib/bastion/ and make sure you select the bastion service checkbox. You do not need to select Secret, because this file only contains public keys which are not secrets.

Connect to the bastion
Once you have applied the services to deploy a new environment or update and existing environment, navigate to the environment's details page. You'll find the hostname for the bastion service in the "Hostname URLs" section.

Copy the hostname for the bastion service. You can now use an SSH terminal to connect as the user bastion as follows:
You can now execute commands on the bastion to reach hosts beyond the bastion server.
Optional: Use the bastion as a jump host
The SSH bastion supports a local configuration you can enable to proxy through the bastion transparently. If you would like to learn more using a proxy jump host, take a look at Tecmint's How to Access a Remote Server Using a Jump Host.
Last updated
Was this helpful?