Use VSCode access and modify remote files to implement in three steps: install RMate on the remote Linux machine; install OpenSSH on local Windows; install extended Remote vScode in VSCODE.
1. Install RMate on the remote Linux machine
Rmate has a lot of Chinese language versions. Here is a Python version. github address:
download and install is relatively simple, just execute the following commands in Linux
wget https://raw.githubusercontent.com/sclukey/rmate-python/master/bin/rmate chmod +x ./rmate mv ./rmate /usr/local/bin/rmate
2. Install OpenSSH in local Window
github address:https://github.com/openssl/openssl/blob/master/INSTALLThis needs to be compiled by itself. It is recommended to use the Window version of the installation package directly:https://www.mls-software.com/opensshd.html
Recommended EXE version. If you download the installation version, you need to set the environment variable in Windows to decompress the BIN directory. The installation of running the SSH command will have the following prompts:
** You can directly run the SSH -Keygen -t RSA command to generate a key pair. Generally, the default folder will be in the .ssh folder in the current user directory. Implementing the remote Linux -free login in the command line of Windows, which is the same as the method in the Linux system. You can in the Authorized_Key file.
To make AUTHORIZED_KEY take effect, you need to modify the sshd_config file, mainly the following three items, you can cancel the notes **
RSAAuthentication yes PubkeyAuthentication yes AuthorizedKeysFile .ssh/authorized_keys
, execute the service SSHD RESTART command to restart the SSHD service
service sshd restart # cat id_rsa.pub >> authorized_keys # Note the path of the file
Note that if the linux login user is not a root user, you need to modify the permissions of the following .ssh folders and Authorized_key files, otherwise it cannot be achieved by password -free login.
chmod 700 .ssh cd .ssh/ chmod 600 authorized_keys
3. Install Remote VSCODE extension
After the installation is complete, click the Start Server in the panel to start the service (this step is necessary)
After opening the terminal ([View] – [Integrated terminal]), enter the following command:
ssh -R 52698:127.0.0.1:52698Login Linux Username@linuxComputer IP address# Example ssh -R 52698:127.0.0.1:52698 [email protected]192.168.1.215 ssh -R 52698:127.0.0.1:52698 [email protected]192.168.1.215 -p 2159 # The above 2159 is the port number, just for example, SSH accesses the remote host through port 22 by default, this situation may change the port, or it may be the forwarding of the port. # rmate -p 52698Linux file name
The result will open the corresponding file:
** can be modified directly.
In addition, if you need to set up an expansion automatic start, just click [Working Area Settings], which will automatically add setting.json files **
In the file, set the following settings.
Finally, if a firewall is turned on, you need to open the 52698 port used.