SSHing into a Remote Host, Through a Jumphost
Last updated:
- Ensure the requirements:
- An architecture with 3 hosts: one for development, one for production, and one jumphost;
- An account
<USERNAME>
created on the production host; - An SSH server installed on the production host, on port 22;
- A public SSH key linked attached to the account;
- A private SSH key placed on the development host, on
<PATH_TO_PRIVATE_KEY>
; and - A project folder on the development host, on
<PATH_TO_SYNCED_FOLDER>
.
- Login to ngrok, eventually with SSO (e.g. GitHub).
- After login, you will be redirected to the setup page. Copy the link to the binary (not.
<BINARY_LINK>
) specific to the production host's architecture. - Login to the production host, and download the binary with
wget <BINARY_LINK>
. - Authenticate yourself to ngrok:
./ngrok config add-authtoken <ACCOUNT_TOKEN>
. - Expose the SSH server using ngrok:
./ngrok tcp 22
. This step will give you a URL respecting the structuretcp://<NGROK_SUBDOMAIN>:<PORT>
. - In the Visual Studio Code installed on the development host, install the SFTP extension.
- In the folder you want to sync, create the file
.vscode/sftp.json
with the content inserted on the end on the list. - In the IDE, run the command "SFTP: Sync Local -> Remote" to upload the initial state of the project folder.
- Furthermore, once you save a file in your project's folder, it will be automatically updated on the remote host too.
{
"name": "Development Host",
"host": "<NGROK_SUBDOMAIN>",
"protocol": "sftp",
"port": <PORT>,
"username": "<USERNAME>",
"privateKeyPath": "<PATH_TO_PRIVATE_KEY>",
"remotePath": "<PATH_TO_SYNCED_FOLDER>",
"uploadOnSave": true,
"useTempFile": false,
"openSsh": false,
"ignore": [".vscode"]
}