local vscode remote debugging and development on Cloud
install remote debugging & programming plugin "Remote Development " on local vscode editor, you can directly modify and debug the code on the server instead of vim. it has code highlighting and completion functions, just like using VScode locally.
1.install ssh-server on remote linux server machine (CentOS).
//show ssh service status, if it is showing the "Loaded: error (Reason: No such file or directory)" which means that you need to install ssh service. If it is appeared "Active: inactive (dead)" which means you should open ssh service. $sudo service sshd status //install ssh (centos) $sudo yum install sshd or $sudo yum install openssh-server //open service, if it is showing "Active: active (running) " means that the service was already start $sudo service sshd start //uninstall ssh $sudo yum remove sshd
use "node --inspect=xxx.xxx.xxx.xxx:9229 xx.js" to appoint a port to remote debugging.
2.install ssh-client on local machine.
//my mac machine was already install git, so it pre-install the ssh-client(Comes pre-installed). or $sudo yum install openssh-server && sudo systemctl start sshd.service && sudo systemctl enable sshd.service $ssh [email protected] //show error: @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @, ECDSA host key for 172.xxx.xxx.xxx has changed and you have requested strict checking. because the ssh will check the public key in ~/.ssh/known_hosts to avoid dns DNS when you connect. the checking weight is based on the StrictHostKeyChecking(no, ask, yes). you need to remove the rsa information by ip in the path "~/.ssh/known_hosts". $vi ~/.ssh/known_hosts find the ip and remove. or $ssh-keygen -R hostname then retry to connect to ssh-server by command: $ssh [email protected]
3.install VSCode & extension pack "Remote Development".
after install remote development, Remote-SSH:Connect to Host->Configure SSH Hosts to choose a config file, prepared to config the host & hostname & username to this file. then save and connect to ssh-server by passward (alse can use public key).
[Optional] While password-based authentication is supported, we recommend setting up key based authentication on the host you plan to connect to by adding your local public SSH key to ~/.ssh/authorized_keys
on the host.
Select Remote-SSH: Connect to Host... from the Command Palette (F1) and enter the host and your user on the host in the input box as follows: user@hostname
.
After a moment, VS Code will connect to the SSH server and set itself up. VS Code will keep you up-to-date using a progress notification and you can see a detailed log in the Remote - SSH
output channel.
After you are connected, you'll be in an empty window. You can then open a folder or workspace on the remote machine using File > Open... or File > Open Workspace...
The window will reload and the folder or workspace you selected will open. If you have multiple VS Code windows open, you can refer to the Status bar to see which one is connected to the host.
Clicking on the Status bar item at any time will provide a list of remote commands while you are connected.
File > Close Remote Connection to disconnect from the host.
more information you can check here: https://code.visualstudio.com/docs/remote/ssh