건설 시스템 SSH 인증 키는 대략 4 단계 공정을 포함한다 :
SSH 클라이언트 : 192.168.1.1의
SSH 서버 : 192.168.1.2
1 클라이언트의 키 쌍을 만듭니다 :
[root@localhost /]# ssh-keygen -t ecdsa
# “ -t ” 用来指定加密算法,这里使用ecdsa,还有一个是dsa。
Generating public/private ecdsa key pair.
Enter file in which to save the key (/root/.ssh/id_ecdsa):
#指定私钥存放位置,若直接按enter,则默认保存在宿主目录中的隐藏文件夹中.ssh下。
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase): #设置私钥短语
Enter same passphrase again: #确认所设置的短语
..........................
+---[ECDSA 256]---+
| .. =oo.+o. |
| .=.= *.o.oo|
| +.= = B oo+|
| . = = B . = |
| . o S o . = |
| + o = o . . |
| = = . . |
| + E . |
| . |
+----[SHA256]-----+
当出现以上提示,则表示创建成功。
개인 키 문구는 원격 연결시 올바른 개인 키 문구를 입력해야합니다 개인 키 파일을 보호하는 데 사용됩니다. 개인 키 문구 설정하면 당신은 무료로 암호 로그인을 달성하기를 연결할 때, 다음,이 방법은 사용하지 않는 것이 좋습니다.
(2) (여기서, 명령이 상기 도면의 두 번째 및 세 번째 단계를 얻을 수있는 간단한 방법을 사용하여) SSH 서버 공개 키 파일을 업로드 :
[root@localhost /]# ssh-copy-id -i ~/.ssh/id_ecdsa.pub [email protected]
# “ -i ” 用来指定公钥文件,“ lisi”是SSH服务器的用户
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_ecdsa.pub"
The authenticity of host '192.168.1.2 (192.168.1.2)' can't be established.
ECDSA key fingerprint is SHA256:uArLTW6MJOgdp+OZQbywwJdlGUEKDmOC62CnU6zyCgA.
ECDSA key fingerprint is MD5:b8:ca:d6:89:a2:42:90:97:02:0a:54:c1:4c:1e:c2:77.
Are you sure you want to continue connecting (yes/no)? yes #输入“yes”
/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
[email protected]'s password: #输入用户“lisi” 的密码
#验证密码后,会自动将公钥文件添加到SSH服务器“ lisi ”用户的宿主目录下的.ssh/authorized_key
Number of key(s) added: 1
Now try logging into the machine, with: "ssh '[email protected]'"
and check to make sure that only the key(s) you wanted were added.
出现上述提示后,则表示上传成功。
검증 키 클라이언트를 사용하여 4 :
[root@localhost /]# ssh [email protected] #请求连接
Enter passphrase for key '/root/.ssh/id_ecdsa':
#输入生成密钥时设置的私钥短语,而不是lv用户的密码了
Last login: Sat May 18 22:13:51 2019
[lv@localhost ~]$ id #查询当前用户的id,结果为登录成功
uid=1000(lisi) gid=1000(lisi) 组=1000(lisi),10(wheel) 环境=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
이 구성에 오류가 발생하면, 항목의 SSHD 서비스가 인증 및 키 공공 도서관 파일의 지정된 위치를 사용할 경우 때문에, SSHD 서비스를 여부 충돌 프로필에주의 영향력있는 원격 연결되어있을 것이다 . 여기 통역 서비스 SSHD 구성 항목은 특정 참조 : https://blog.51cto.com/14154700/2402246