windows 中打开powershell 运行以下命令
ssh-keygen -t rsa -b 4096 -C your_email@example.com
运行以下命令查看公钥
Get-Content ~/.ssh/id_rsa.pub
登录linux服务器运行以下命令
mkdir -p ~/.ssh
chmod 700 ~/.ssh
echo “粘贴公钥内容” >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
在Windows 11上创建或编辑C:\Users\用户名\.ssh\config文件:
Host mylinux
HostName linux_host_ip
User username
IdentityFile ~/.ssh/id_rsa
IdentitiesOnly yes