乐趣区

关于python:SSH免密登陆Win登陆linux

在本地运行 git bash(windows)

ssh-keygen -t rsa -C "xxx@qq.com"

一路回车

Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:/k7eBzEwIUHIjhq09GBEkoRMLKKbCV4XzyhHJ3ffsj0 vansenb@foxmail.com
The key's randomart image is:
+---[RSA 3072]----+
|%O   o o+...     |
|O+. .++o oo      |
|=  ..+O.. .o.    |
|o  o.+oo   +o.   |
|o+. +   S   +o   |
|+.     .   ..E   |
|        . .  ..  |
|         + .  .  |
|         .+ ..   |
+----[SHA256]-----+

查看密钥文件

cat ~/.ssh/id_rsa.pub

ssh-rsa 开始,直到集体标识完结,全副复制

登陆到服务器 (linux),将公钥写入文件

cd ~/.ssh && vim authorized_keys

应用 vim 编辑器关上文件后按 i 键进入编辑模式,应用键盘快捷键 Ctr V 粘贴方才复制的公钥字符串。接着按 ESC 键进入 vim 编辑器的命令行模式,输出 :wq 并回车。

免密登陆

ssh root@10.1.1.1

第一次登陆提醒

The authenticity of host '10.1.1.1 (10.1.1.1)' can't be established.
ECDSA key fingerprint is SHA256:nGvmS+JKzQf1gG+Nzc0QN/qS6xSp1iV0rJFP1dILel4.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes

输出 yes 即可

Warning: Permanently added '10.1.1.1' (ECDSA) to the list of known hosts.
Last login: Wed Dec 23 21:43:28 2020 from 111.94.33.65

Welcome to Cloud Elastic Compute Service !

![Uploading file…]()

欢送关注同名公众号:大鹏学开发

退出移动版