vscode远程连接ssh

一. 使用vscode里的ssh查件连不上远程的解决方法

  1. 删除Windows上的known_host文件,该文件会在连接之后自动生成,用于验证远程服务器的身份。

  2. konwn_host和id_rsa,id_rsa.pub的关系

    (1)konwn_host用于客户端验证远程服务器的身份,id_rsa用于服务器验证客户端的身份,具体来说id_rsa生成一个随机签名发送到服务器,服务器用事先报错好的id_rsa.pub来验证该签名,从而实现登录。

    (2)所以要实现ssh远程连接必须要保证konwn_host是正确的,不正确就把其删除。

    (3)再比如连接github服务器,我们同样需要konwn_host验证github服务器的身份,同时需要github_rsa进行登录。
    gitbash中使用ssh代理免密登录记得ssh-keygen加上-f ~/.ssh/密钥对名称,来实现自定义密钥名
    (4)需要注意我们要在/etc/profiles中新增下面代码,保证能够每次启动都添加ssh代理

    bash 复制代码
    ssh_proxy_add(){
            eval $(ssh-agent -s)
            ssh-add ~/.ssh/id_rsa
            ssh-add ~/.ssh/github_rsa
    }
    ssh_proxy_add

二. 修改~/.ssh/config文件实现免密ssh连接

  1. 把公钥添加到要登录用户的~/.ssh/authorized_keys中
  2. 修改Windows的~/.ssh/config添加IdentityFile 指定私钥的位置
c 复制代码
Host remote
  HostName 47.108.186.16
  User root
  Port 22
  IdentityFile "C:\Users\Administrator\.ssh\aliyun_rsa"

链接

相关推荐
Magnum Lehar29 分钟前
vscode游戏引擎的build-clean配置
ide·vscode·游戏引擎
Magnum Lehar33 分钟前
vscode游戏引擎的build-all全局配置
ide·vscode·游戏引擎
世由心生40 分钟前
[从0到1]环境准备--anaconda与pycharm的安装
ide·python·pycharm
程序猿小D1 小时前
第27节 Node.js Buffer
linux·开发语言·vscode·node.js·c#·编辑器·vim
大鼻噶喳1 小时前
使用VSCode开发MCU,FreeRTOS进Hard_Fault调试
vscode·单片机
0点51 胜3 小时前
visual studio小番茄插件某些快捷键失效
ide·visual studio
一个处女座的暖男程序猿3 小时前
在pyCharm中创建新的conda环境
ide·pycharm·conda
我想吹水5 小时前
vscode python debugger 如何调试老版本python
vscode·python·python debugger
ScilogyHunter17 小时前
vscode的c工程配置文件详解
c语言·ide·vscode
摆渡搜不到你18 小时前
Visual Studio Code 1.101.0 官方版
ide·vscode·编辑器