今天试用了一下 VSCode 的新插件:远程开发插件,体验很不错,它可以:
让你要本地打开远程开发机下有代码,并提供和本地一样的开发体验 在 VSCode 中打开远程的终端 在不同远程开发机上配置不同的插件,把插件装在远程的目的是让操作中更流畅 你还可以在本地调试远程代码:断点、单步等一样都都没少 支持 SSH 隧道 (SSH Tunnel) 的连接方式,为自己你便可以选择不在家调试公司电脑下有代码了。 ……
本文将以 SSH 连接的方式,做这些入门介绍,更多高级功能还需你要使用过程中慢慢发掘。
配置步骤
1 在 VSCode 扩展栏中搜索 Remote - SSH 插件,点击需要安装
2 使用 ssh-keygen 工具在本机创建 ssh 秘钥,创建时一路回车即可 (注意:Remote-SSH 插件不支持输入账号密码的连接方式,首选的登录方式为使用非对称秘钥登录)
$ ssh-keygenEnter file in which to save the key (/Users/fengyajie/.ssh/id_rsa): Enter passphrase (empty for no passphrase):Enter same passphrase again:Your identification has been saved in /Users/fengyajie/.ssh/id_rsa.Your public key has been saved in /Users/fengyajie/.ssh/id_rsa.pub.The key fingerprint is:The keys randomart image is:+---[RSA 2048]----+ .oo*++.+o++ +o Oo+ + + . . o+ o o .. o . +o . o o o . S+ .o . . . +.E . .. o=.+ . . .. .=*.. .. +----[SHA256]-----+
3 将产生非常合适公钥发送到远端(使用 ssh-copy-id 工具),你可以可以将下面的 user@your_remote_host 修改为你开发机的用户名和主机名
$ ssh-copy-id -i ~/.ssh/id_rsa.pub user@your_remote_hostusr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: /Users/fengyajie/.ssh/id_rsa.pub/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keysNumber of key(s) added: 1Now try logging into the machine, with: ssh user@your_remote_hostand check to make sure that only the key(s) you wanted were added.
4 试一下连接,正常情况下你由于就可以直接登录到远端机器了
$ ssh user@your_remote_hostWelcome to Alibaba Cloud Elastic Compute Service !Last login: Thu Jun 6 20:32:13 2019 from $local_iproot@iZwz946zuZ:~#
连接远端机器
上面配置完成后,你一直在可以使用 VSCode 连接到远端机器了,打开 VSCode,敲入 F1键,输入 Remote-SSH:Connect to Host,回车
然后输入你刚才配置非常合适 user@your_remote_host,回车
此时 VSCode 会打开这些新的窗口,在既然是的窗口的左下角,你会观察到这些绿色的 SSH 状态条,表示此时你的 VSCode 以前连上了远程的开发机,如下
然后再,你一直在可以打开左上角的文件管理侧边栏,点击 Open Folder,此时你会疑惑的发现,远端的 home 目录被列上我去:
至此,你以前在本地开启了这些「远端开发环境」,然后再你的开发任务再也不受远程环境的限制了,能有这些体验,因此要感谢一下微软公司的贡献,觉着是一款良心之作。
以上仅只这一点都没入门介绍,可以让你快速的把既然是的插件用起来,更多高级功能,因此建议你要阅读官方文档中的内容。


还没有内容