Windows 配置 SSH 免密登录 Linux 服务器
SSH PowerShell Git About 1,049 words免密登录
只需要使用如下命令即可直接登录服务器Shell
窗口,无需输入密码。
ssh root@192.168.1.100
解决方法
使用ssh-keygen
生成id_rsa
私钥,id_rsa.pub
公钥,生成的文件在%HOMEPATH%/.ssh
用户目录下的.ssh
文件夹中。
ssh-keygen.exe
使用Git Bash
命令行执行ssh-copy-id
,将公钥拷贝到需要登录的服务器,指定用户名和IP
地址。
也可以直接复制id_rsa.pub
中的内容,粘贴到目标服务器的~/.ssh/
目录下的authorized_keys
文件(authorized_keys
文件没有可以新建)。
ssh-copy-id -i ./id_rsa.pub root@192.168.1.100
输出
$ ssh-copy-id -i ./id_rsa.pub root@192.168.1.100
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "./id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@192.168.1.100's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'root@192.168.1.100'"
and check to make sure that only the key(s) you wanted were added.
确认
登录目标服务器,在~/.ssh/
目录下是否存在authorized_keys
文件。
authorized_keys
文件中的内容与Windows
推送上去的id_rsa.pub
一致。
这样就可以在Windows
上直接使用ssh root@192.168.1.100
连接目标服务器了,无需再输入密码。
Views: 3,271 · Posted: 2022-06-29
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb/LiteNote扫描下方二维码关注公众号和小程序↓↓↓
Loading...