본문 바로가기
★━Server OS〃/1. Linux

ssh 접속시 pw 안물어보기

by Raynee 2017. 8. 2.
반응형

자동 백업을 할때 유용하다.

 

[root@centos2 ~]# ssh 10.0.2.4
The authenticity of host '10.0.2.4 (10.0.2.4)' can't be established.
ECDSA key fingerprint is 63:41:b2:9d:cd:0d:da:ad:38:12:39:1f:82:bf:f9:32.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.0.2.4' (ECDSA) to the list of known hosts.
root@10.0.2.4's password:
Last login: Wed Aug  2 14:53:48 2017
[root@centos1 ~]#
[root@centos1 ~]#

 

 



[root@centos2 ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
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:
06:83:61:41:54:6e:95:e1:14:ce:81:68:d5:29:6f:ca root@centos2
The key's randomart image is:
+--[ RSA 2048]----+
|   o*=oo*=       |
|   .o+o*+.       |
|   .. =o+        |
|     . oo        |
|     . oS        |
|      E.         |
|                 |
|                 |
|                 |
+-----------------+
[root@centos2 ~]#
[root@centos2 ~]#
[root@centos2 ~]#
[root@centos2 ~]#
[root@centos2 ~]# ls -l /root/.ssh
total 16
-rw-------. 1 root root  394 Aug  2 16:47 authorized_keys
-rw-------. 1 root root 1675 Aug  2 17:14 id_rsa
-rw-r--r--. 1 root root  394 Aug  2 17:14 id_rsa.pub
-rw-r--r--. 1 root root  340 Aug  2 17:01 known_hosts
[root@centos2 ~]#
[root@centos2 ~]#
[root@centos2 ~]#
[root@centos2 ~]#
[root@centos2 ~]#
[root@centos2 ~]#
[root@centos2 ~]# cat authorized_keys
cat: authorized_keys: No such file or directory
[root@centos2 ~]#
[root@centos2 ~]#
[root@centos2 ~]# cd .ssh
[root@centos2 .ssh]# ls
authorized_keys  id_rsa  id_rsa.pub  known_hosts
[root@centos2 .ssh]# cat authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCyIaznsP6rbBo6Ieb/Jhn1iD1/CUOadevuNF4ycuZ3Kd5VZxfBMI9hfwCn4fAPiVSuXK1tKdfEGnWB5jblRZ+l6pqK+KdAb3TqdQk2AM39IKkseYhdbKIWIWvPtF2gisPzZoi3o37kzuvvEfJ+5D7yeLAIV7qkvC9rq55VLJyhjYSTUbX4R750yJyZhd8vAdddFOEOR4+J8Ws59UBSzm7ed7R9z5yd6NHEDCQBrg5EaQmlM+aP3MrtBlYFMFjrHNFReHUhPLm8isOLPxIruJtlWRYAEO00VnUglLD9WYa1PdrE63VKGKYjFcafEKa6BwWwVk/cOUMmyA8ZJeveNMVL root@centos1
[root@centos2 .ssh]#
[root@centos2 .ssh]#
[root@centos2 .ssh]#
[root@centos2 .ssh]#
[root@centos2 .ssh]# ssh-copy-id -i id_rsa.pub 10.0.2.4
/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@10.0.2.4's password:

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh '10.0.2.4'"
and check to make sure that only the key(s) you wanted were added.

[root@centos2 .ssh]#
[root@centos2 .ssh]#
[root@centos2 .ssh]#
[root@centos2 .ssh]#
[root@centos2 .ssh]#
[root@centos2 .ssh]#
[root@centos2 .ssh]# ssh-copy-id -i id_rsa.pub 10.0.2.5
/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@10.0.2.5's password:

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh '10.0.2.5'"
and check to make sure that only the key(s) you wanted were added.

[root@centos2 .ssh]#
[root@centos2 .ssh]#
[root@centos2 .ssh]# ssh 10.0.2.4
Last login: Wed Aug  2 16:50:27 2017 from 10.0.2.5
[root@centos1 ~]# ssh 10.0.2.5
Last login: Wed Aug  2 17:14:05 2017 from 10.0.2.4
[root@centos2 ~]#
[root@centos2 ~]#

반응형

댓글