## 远程主机安装 ssh-server ``` bash # 根据本地 OS 选择安装方式 $ sudo apt install openssh-server ``` ## 本地主机安装 ssh-client ``` bash 根据本地 OS 选择安装方式,macOS 自带,winOS 安装了 git 客户端就有了。 ``` ## 安装 Remote Development 插件 * [Remote Development 相关介绍](https://code.visualstudio.com/docs/remote/ssh#_remembering-hosts-you-connect-to-frequently) * [Remote Development 插件地址](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack) ## 配置 Remote Development ``` ssh Host 自己腾讯云 HostName your_IP User your_username Port 22 IdentityFile "your_path/.ssh/id_rsa" ``` <img width="1439" alt="1" src="https://user-images.githubusercontent.com/22309277/68083833-aaf8d980-fe68-11e9-895a-2a96d4504da3.png"> <img width="931" alt="2" src="https://user-images.githubusercontent.com/22309277/68083840-bc41e600-fe68-11e9-939f-34ebfc67beb2.png"> ## 连接远程主机 <img width="1004" alt="3" src="https://user-images.githubusercontent.com/22309277/68083851-d11e7980-fe68-11e9-901e-d4beb590e360.png"> <img width="1439" alt="4" src="https://user-images.githubusercontent.com/22309277/68083853-d7acf100-fe68-11e9-85b6-7729c81f4326.png"> <img width="1024" alt="5" src="https://user-images.githubusercontent.com/22309277/68083855-dc71a500-fe68-11e9-969d-7ef0a66798f6.png"> ## 选择 ssh 无密码远程登陆 1. 首先在客户端生成 ssh 密钥(如果已经生成了的话忽略这步) ``` bash $ ssh-keygen ``` 2. 拷贝本地公钥到远程服务器 ``` bash $ ssh-copy-id username@192.168.1.1 ``` 3. 将公钥加入 `authorized_keys` 文件 ``` bash $ cat ~/.ssh/your_id_rsa.pub >> ~/.ssh/authorized_keys ``` 4. 以后登录就不用输密码了
远程主机安装 ssh-server
# 根据本地 OS 选择安装方式 $ sudo apt install openssh-server本地主机安装 ssh-client
安装 Remote Development 插件
配置 Remote Development
连接远程主机
选择 ssh 无密码远程登陆
authorized_keys文件