vscode连接远程服务器 报错及解决

今天费了好大劲终于成功在vscode上连接远程linux服务器,特此记录一下对我有帮助的链接。
之前一直是通过黑框框ssh

ssh xxx@ip

Mac 使用 VSCode远程连接服务器
Mac 配置 VSCode Remote-SSH
解决报错:vscode使用Remote-SSH插件无法连接远程LINUX服务器

解决报错:VSCode Server installation process already in progress - waiting and retrying

mac 传送文件到linux :scp

解决报错:解决vscode连接服务器时一直在downloading

commit_id=xxx (很长一串,在报错信息中找)

# Download url is: https://update.code.visualstudio.com/commit:${commit_id}/server-linux-x64/stable
curl -sSL "https://update.code.visualstudio.com/commit:${commit_id}/server-linux-x64/stable" -o vscode-server-linux-x64.tar.gz
# or 
scp -r【本地文件的路径】【服务器用户名】@【服务器地址】:【服务器上存放文件的路径】

mkdir -p ~/.vscode-server/bin/${commit_id}
# assume that you upload vscode-server-linux-x64.tar.gz to /tmp dir
tar zxvf /tmp/vscode-server-linux-x64.tar.gz -C ~/.vscode-server/bin/${commit_id} --strip 1
touch ~/.vscode-server/bin/${commit_id}/0

PS: vscode 版本更新需要重新执行上述操作(若仍然无法成功下载 vscode-server)
or If the above operation process is too troublesome,you can try try this: See this Gist download-vs-code-server for a more complete shell script that will also get the latest released commit SHA (from GitHub) so you do not need to supply it yourself.

2022.11.22 更新

ssh-keygen命令使用

使用 vscode + Remote-SSH 插件 + vscode-server 进行远程开发

配置免密登录:

1. 生成 SSH 密钥对

ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa-remote-ssh

参数说明:
-t 指定要创建的类型
-b 密钥长度
-f 指定用来保存密钥的文件名
id_rsa-remote-ssh 名字可以随意定义

2. 将 SSH 公钥添加到远程服务器

在远程服务器的 ~/.ssh目录下创建 authorized_keys 文件(若不存在得话),并将本地 SSH 公钥(.pub)中的内容添加到该文件中。此后,任何从本地发起的指向远程服务器的 SSH 连接请求(如登陆、scp 文件传输等)将不再需要输入登陆密码

你可能感兴趣的:(vscode,服务器,linux)