1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > Mac配置vscode ssh远程连接主机(远程办公必备)

Mac配置vscode ssh远程连接主机(远程办公必备)

时间:2022-11-11 18:30:46

相关推荐

Mac配置vscode ssh远程连接主机(远程办公必备)

终端操作

使用ssh-keygen命令创建密钥,会在~/.ssh/目录下会生成两个文件id_rsa-remote-ssh和id_rsa-remote-ssh.pub。

ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa-remote-ssh拷贝公钥

pbcopy < ~/.ssh/id_rsa-remote-ssh.pubssh登陆远程服务器

ssh user@host创建/修改authorized_keys文件

vim .ssh/authorized_keys将刚刚 pbcopy 命令拷贝的内容粘贴到 authorized_keys 里并保存去掉 /etc/ssh/sshd_config 中 PubkeyAuthentication 前的 # 号重启远程服务器的ssh服务

systemctl restart sshd.service

vscode Remote-SSH插件配置

可以直接从vscode的扩展中下载,下载完成后左侧会出现Remote Explorer图标。

创建配置文件/Users/your-host-name/.ssh/config并填入

Host xxx # xxx 自定义连接名称User xxxx # root 远程服务器账户名称HostName xxx.xxx.xxx.xxx # 远程服务器地址IdentityFile ~/.ssh/id_rsa-remote-ssh.pub # 本地密钥所在位置

点进Remote Explorer即可

参考

https://qlzhu.github.io/blog/15892/

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。