Table of contents
1 Install VSCode
1.1 download
1. Official website download address https://code.visualstudio.com/
2. Select the corresponding version of your own system to download:
1.2 Installation
1. Double-click the downloaded exe to install
2. Browse the installation path
3. Add to the start menu, here is the default
4. Check as shown in the figure
Note: After checking " Register Code as a supported file type editor ", many text formats will be changed to open with VSCode
5. Confirm the information and install
2 Install OpenSSH
1. Run PowerShell as an administrator
2. Input: Get-WindowsCapability -Online | ? Name -like 'OpenSSH*'
not installed as shown in the figure below
3. Skip this step if it is installed, and execute if it is not installed:
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
After the installation is complete, as shown in the figure below:
4. Verify, input: ssh
as shown in the figure below, the installation is successful:
3 VSCode configuration ssh
1. Click the extension in the left toolbar, search for "ssh", and select the first one to install (here already installed)
2. Click the "Settings" button in the lower left corner, and then click "Settings":
3. Find "Show Login Terminal" and check this option
4 VSCode connects to remote server
1. Click "Remote" in the left toolbar to view the remote connection, and then click **+**
2. Click the Add button, enter the address of the remote server, account number and ip to modify by yourself, press Enter to save the
input information to the configuration file
3, right-click to select, as shown below,
select the system to be used to
enter the password, and then succeed Connect to a remote server.
4. You can choose the files of the remote server to operate
5 VSCode connects to the container in the remote server docker
1、
docker run -it --name 容器名 -v 服务器文件目录:容器目录 -p vcscode连接端口:22 镜像id /bin/bash
2. After entering the container, download and install openssh.
The first method:
yum update && yum install -y --no-install-recommends openssh-server
The second method:
yum update
yum install openssh-server
yum install openssh-client
Ubuntu changes yum to apt-get
without reporting an error during the installation process. If there is an sshd_config configuration file in the /etc/ssh directory, the installation is successful
3. Modify the configuration file
vim /etc/ssh/sshd_config
Uncomment the " # " in the following line
Port 22
ListenAddress 0.0.0.0
ListenAddress::
PermitRootLogin yes
PubkeyAuthentication yes
PasswordAuthentication yes
4. Set the root password for VScode login
command: passwd and
enter it twice as prompted
5. Restart the ssh service
ubuntu: service ssh restart (use the command service ssh status to view the status)
centos: /etc/init.d/ssh restart (/etc/init.d/ssh status)
or /usr/sbin/sshd -D &
If the above error occurs, you need to perform the following settings in order:
ssh-keygen -q -t rsa -b 2048 -f /etc/ssh/ssh_host_rsa_key -N ''
ssh-keygen -q -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N ''
ssh-keygen -t dsa -f /etc/ssh/ssh_host_ed25519_key -N ''
Then restart the ssh service, the process number will be returned if the startup is successful
Check whether the ssh service is enabled:ps -e | grep sshd
Check whether port 22 is enabled for listening:
yum install net-tools
netstat -an | grep 22
6. Then connect according to the way of connecting to the server
Host 名称任意
HostName 服务器ip地址
Port 输入上面设置的vscode连接的端口
User root