windows 10 ssh免密登录linux

windows 10 ssh使用密钥登录linux

桌面左下角搜素栏里输入powershell 找到powershell
在win10 的 powershell里面输入
ssh-keygen -t rsa -C “你的email或者名字等任意字符串都行”
回车

会在C:\Users\你的用户名\.ssh 会生成一对秘钥, .pub后缀的是公钥,用于上传到服务器的.

在linux服务器的 /root/.ssh/authorized_keys 文件里面 填写上面生成的公钥的内容.

或者用ssh-copy-id命令写入

ssh-copy-id -i ~/.ssh/id_rsa.pub user@serverip

再在windows C:\Users\用户名\ssh\config 文件写入快速登录的方法

Host myserver1
  HostName 你的服务器ip
  User root
  Port 22
  IdentityFile C:\Users\用户名\.ssh\id_rsa

myserver1是给服务器起的名字,自己命名
下次 用 ssh myserver1 命令就能登录服务器了 .就不用 ssh user@ip 了.