您当前的位置: 首页 >  vscode

RuiH.AI

暂无认证

  • 0浏览

    0关注

    274博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Ubuntu:配置VSCode remote ssh进行远程连接

RuiH.AI 发布时间:2021-12-11 16:37:37 ,浏览量:0

VSCode remote ssh远程连接
  • Step 1
  • Step 2
  • Step 3
  • Step 4
  • VSCode remote ssh连接服务器时的一个报错

Step 1

在VSCode插件栏搜索Remote-SSH,下载安装

Step 2

通过ssh-keygen为本地主机生成私钥和公钥,这个之前写过就不再重复了。

生成的公钥存在本地的路径~/.ssh/中,假设公钥名为id_rsa.pub

Step 3

将本地公钥配置到服务器上,假设服务器ip为xxx.xxx.xxx.xxx:

ssh-copy-id -i "~/.ssh/id_rsa.pub" -p 2222 xxx.xxx.xxx.xxx
Step 4

修改ssh的配置文件:

gedit ~/.ssh/config

修改格式如下:

Host myserver
		HostName xxx.xxx.xxx.xxx
		Port 2222
		User me
		IdentityFile ~/.ssh/id_rsa

其中,Host是服务器名称可自定,HostName表示服务器ip地址,port是登录服务器端口,User为登录用户名,IdentityFile代表本地私钥位置。

然后VSCode remote面板就有相应的服务器名字了,右击Connect就OK

VSCode remote ssh连接服务器时的一个报错

报错信息:

bash: line: syntax error near unexpected token '('
-sh: 4: function: not found
-sh: 69: [[: not found
-sh: 90: [[: not found

解决方法: Ctrl+Shift+P打开VS命令栏输入remote ssh,打开Settings,找到Remote.SSH.User Local Server这一项,disable以后问题解决。

关注
打赏
1658651101
查看更多评论
立即登录/注册

微信扫码登录

0.0590s