Install and configure Remote-SSH
First open your VSCode, find Extensions, search Remote, Download Remote-Developoment plugin will automatically install other Remote plug-in, which will include Remote-SSH:
enter setup, search ssh
, find and select the Remote-SSH Expansion of the ShowLoginTerminal
option because at the time of connection, the terminal will let you enter yes or password, etc.
then, you need to configure your Linux server address information, press CTRL+SHIFT+P
, search ssh
, find Open Configuration File
the option
and then enter your address information:
Linux install OpenSSH-Server and Configuration
Ubuntu
// 先卸载
sudo apt-get remove openssh-server
// 安装
sudo apt-get install openssh-server
//重启sshd服务
sudo service ssh --full-restart
//自动启动
sudo systemctl enable ssh
CentOS
//安装
yum install -y openssl openssh-server
//重启sshd服务
systemctl restart sshd.service
//自动启动
systemctl enable sshd
Edit Profile
Backup configuration files
sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.backup
Edit Profile
sudo vim /etc/ssh/sshd_config
Configuration file, add the following configuration:
port can be customized
using a password
save and restart sshd server restart command has been given above.
SSH connection with password
Find your Linux server configuration:
Enter the password, and then press Enter:
then open the folder to begin writing code:
use CTRL + SHIFT + ~
brings up the terminal, the terminal can operate in command, open the file you can write code.
Use key free password
Client configuration
to ensure that local Windows operating system has been installed ssh
generate SSH keys for:
ssh-keygen -t rsa -b 4096
(-b 4096 rsa secret key generated to represent a length of 4096 bit) input after the instruction, let us specify the secret key to generate a file directory, can skip directly enter generated directory c:\user\WINDSUN\.ssh
generated under this directory : id-rsa
and id-rsa.pub
the two documents, the first one is the private key file, the second is the public key file, the user name is your computer user name
Server-side configuration
detection ssh service is started
netstat -ntlp | grep ssh
Modify the configuration file
vim /etc/ssh/sshd_config
Here the most important thing is we need to PubkeyAuthentication
be configured to yes
allow the use of key authentication to log on the way.
Finally, the client public key id-rsa.pub
upload files to the corresponding user .ssh root folder, the contents will enter the public key .ssh copied to authorized_keys
file
cp id_rsa.pub authorized_keys
Then set the appropriate file permissions
chmod 700 .ssh
chmod 600 .ssh/authorized_keys
The Remote-SSH VS plug-in configuration
settings vscode of Remote - SSH plug-in configuration file:
Host Aliyun
HostName X.X.X.X
User XXX
IdentityFile C:\Users\WINDSUN\.ssh\id_rsa
Problems encountered
If the message pipeline error, the problem may be
- ssh to your Linux server is configured with the question of whether to solve the problem by modifying the configuration of the test.
- Delete ".vscode-server" directory created on the server. This is a hidden directory created in your home directory (you can use the "ls -la" show all files I believe). Probably some incorrect data is cached in there, so delete the directory will make your situation more clean. After deleting, you can try to reconnect via remote-ssh on vscode.
- Problems encountered different operating system versions may also be different.