A quick tutorial that makes your remote server work as a local one.
launch a terminal in the local machine, excute the following command:
ssh-keygen
input Enter for all the following steps and then you will find two files generated in ~/.ssh
folder:
id_rsa
id_rsa.pub
excute the following command:
ssh-copy-id [username]@[host]
# if you log in to your lab server via Liverpool gateway,
# the host should be the host_gateway: ssh1.csc.liv.ac.uk
input passwords and then you should log in to the remote server successfully.
now let us have a sanity test:
# 1/2: Log in to the gateway
ssh [username]@[host_gateway]
# 2/2: Log in to your lab server
ssh [host_lab]
### Here is my configuration for your reference ###
# 1/2
ssh [email protected]
# 2/2
ssh rahul2
if in both steps you are not asked for a password (since we have configured the SSH keys), then you can safely move on to the next step. Otherwise, check carefully and repeat the previous steps.
configure a shortcut to log in to the remote server
cd ~/.ssh
touch config
open config
with an editor and write the following configurations:
Host [customized_name_1]
HostName [host_gateway]
User [username]
Host [customized_name_2]
HostName host_lab
User [username]
ProxyCommand ssh [username]@[host_gateway] nc %h %p
### Here is my configuration for your reference ###
Host liv
HostName ssh1.csc.liv.ac.uk
User ramdrop
Host rahul2
HostName rahul2
User ramdrop
ProxyCommand ssh [email protected] nc %h %p
now you shou be able to log in to the remote server with the shourcuts above:
ssh [customized_name_1]
# or
ssh [customized_name_2]
### Here is my commands for your reference ###
# log in to the gateway
ssh liv
# or log in to the lab server directly
ssh rahul2
Follow the official instructions: https://code.visualstudio.com/
Remote - SSH
(1) launch VS Code Quick Open (Ctrl+P), paste the following command, and press Enter.
ext install ms-vscode-remote.remote-ssh
(2) then in the navigation bar, an icon called Remote Explorer will appear as is shown in the picture, and click it.
(3) right-click the SSH Targets(e.g. liv, rahul2)>Connect to Host in New Window. Now you should be able to log in to the server successfully (it will take a bit longer at the first attempt).
(4) use terminal on the remote machine: in VS Code menu bar, click Terminal>New Teminal, now you can use terminal as in local machine
(5) browse folder: if you want to browse a specific folder, then you execute code [directory]
in the terminal. A new window will pop up accordingly, you can view the folder in the Explorer (in the navigation bar).
(6) debug python file:
launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
ext install ms-python.python
in VS Code menu bar, click Run>Add Configuration>Python File
switch to the python file tab and click Run>Start Debug