今年5月左右微软给vscode加了新操作,有了官方的远程连接的插件,不过好像现在只在insider版本里提供。要安装的话直接在插件里搜索Remote,安装Remote Development这一套就行了。
服务器上操作
这里配置一下使用ssh key登录,相对于输密码比较安全(其实是我懒得每次都敲密码)。首先在服务器上生成一对公私钥
root@itemqqSS:~# ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Created directory '/root/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: SHA256:RWDHVoBeg7jvzTdC/nPPTwemzGl0vogQwUzmooas root@itemqqSS The key's randomart image is: +---[RSA 2048]----+ | o=*+o. | | . o==== | | . o+o +.. | | . . .o.. | | . .S . + | | . o. .+ * . | | . .o=. * . o| |E .o=++..+.| | .+o+..=| +----[SHA256]-----+
这里最好不要再用passphrase了。。直接回车就行。。主要是图省事,加了之后vscode的自动连接似乎不是很方便。
继续阅读“配置vscode连接远程服务器”