Ever code .
on a remote server? Then realise your mistake and feel like a fool? Well, now you don't have to!
Reverse Remote VSCode is simple solution to run the code .
command on a remote server and open the VSCode editor locally using the Remote-SSH extension. This tutorial will guide you through the process of setting up Open Remote VSCode for your bash shell.
- Bash shell
- VSCode installed on your local machine
- Remote-SSH extension installed in VSCode
- SSH access to your remote server
- reverse_remote_vscode.sh (local)
- creates Reverse SSH tunnel to the remote server
- listens for the
code .
command from the remote server
- open_vscode.sh: (remote) passes the
code .
command to the local machine
PORT=1234
REMOTEUSER=yourremoteuser
REMOTESERVER=yourremoteserver
chmod +x reverse_remote_vscode.sh
-
Edit your
~/.bashrc
filenano ~/.bashrc
-
Add:
source /path/to/script/reverse_remote_vscode.sh &
to file -
Reload shell
source ~/.bashrc
scp bin/open_vscode.sh user@remote-server:/home/user/bin/open_vscode.sh
-
Make the script executable
chmod +x /home/user/bin/open_vscode.sh
-
Add the following line to your remote server's .bashrc or .bash_aliases file:
nano ~/.bash_aliases
alias code="/path/to/open_vscode.sh"
note: you can use any alias you like, like
rcode
or something if this is confusing -
Reload shell
source ~/.bashrc
On your remote server run the following command and watch the magic happen!
code .
(current working directory)
also works with:
code full/path/to/folder
code ./path/to/folder