1.远程主机安装ssh-server
服务器端用apt-get install openssh-server -y
安装
2.本地主机安装ssh-client
openssh-windows下载提取码:1111
3.安装vscode
4.安装Remote Development插件
搜索Remote Development
5.通过ctrl+shift+p打开设置Remote-SSH-Settings,设置Remote.SSH:Show Login Terminal为true
6.连接远程主机
7.选择Remote-SSH:Connect to Host->Configure SSH Hosts->选择一个config
8.配置config的信息,Host是自己给这份配置文件起的名字,HostName是远程主机的IP地址,User是登录名
host配置在
C:\Windows\System32\drivers\etc\hosts
配置格式:在文件末尾追加 10.210.166.234 xiaoyu-ubuntu
9.选择密码登录,需要在命令行输入密码登陆
成功登录
/*解决windows下vscode配置远程开发后 用ssh 连接报Bad owner or permissions on C:\\Users\\Administrator/.ssh/config 错误问题解决*/
git clone https://github.com/PowerShell/openssh-portable.git //下载openssh-portable
.\FixUserFilePermissions.ps1 -Confirm:$false //执行该命令,如果报无法加载文件 FixUserFil ePermissions.ps1,因为在此系统上禁止运行脚本就执行命令:Set-ExecutionPolicy RemoteSigned(回车输入Y,然后在执行一次该命令,回车输入N恢复默认配置)
10.选择ssh无密码远程登陆
ssh-keygen -t rsa
ssh-copy-id 用户名@IP
11.基本使用