Windows 配置 SSH 免密登录 Linux 服务器
SSH PowerShell Git 大约 1051 字免密登录
只需要使用如下命令即可直接登录服务器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
连接目标服务器了,无需再输入密码。
阅读 1718 · 发布于 2022-06-29
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb扫描下方二维码关注公众号和小程序↓↓↓

昵称:
随便看看
换一批
-
AndroidStudio 导入 aar 包阅读 3151
-
Android VideoView 播放本地视频短暂黑屏的解决方法阅读 5614
-
Linux 网络状态工具 ss,代替 netstat阅读 14257
-
Kubernetes 数据存储 PV 和 PVC阅读 1104
-
Go 数组和切片阅读 1459
-
Linux 之 CentOS gcc 版本升级为 4.8.2 方法阅读 1869
-
常用开源协议以及是否能够商用阅读 7468
-
MySQL 之 explain/desc type 字段阅读 2008
-
Android 使用 tools schemas 预览 UI阅读 2060
-
HTML input 输入框禁止显示输入过的历史数据阅读 1538