SSH login without password
前言:
最近呢!覺得一直用 SSH 登入,但是輸入密碼很煩,所以特地去找文章研究一下。
環境:
最近呢!覺得一直用 SSH 登入,但是輸入密碼很煩,所以特地去找文章研究一下。
環境:
- ubuntu 17
- zabbix(Server)
- IP 192.168.85.142
- openssh
- ubuntu 17
- zabbix-mysql(Client)
- IP 192.168.85.143
- openssh
1. 一般使用者
itachi@zabbix:~$ ssh-keygen # 產 key
Generating public/private rsa key pair.
Enter file in which to save the key (/home/itachi/.ssh/id_rsa):
Created directory '/home/itachi/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/itachi/.ssh/id_rsa.
Your public key has been saved in /home/itachi/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:m9C1oxYJcpb3vlnHWwpeILFGLN679DNhp/zvMbyOPb8 itachi@zabbix
The key's randomart image is:
+---[RSA 2048]----+
| |
| . . |
| . = o = |
| + = B + |
| . S O . |
| . B +ooo |
| = +oo+++.|
| . . B=+o=+|
| + o==EB|
+----[SHA256]-----+
itachi@zabbix:~$ ls -al | grep ssh
drwx------ 2 itachi itachi 4096 Dec 5 17:19 .ssh
itachi@zabbix:~$ ls -l .ssh/
total 8
-rw------- 1 itachi itachi 1675 Dec 5 17:19 id_rsa # private key
-rw-r--r-- 1 itachi itachi 395 Dec 5 17:19 id_rsa.pub # public key
iitachi@zabbix:~$ ssh-copy-id -i /home/itachi/.ssh/id_rsa.pub itachi@192.168.85.143
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/itachi/.ssh/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
itachi@192.168.85.143's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'itachi@192.168.85.143'"
and check to make sure that only the key(s) you wanted were added.
iitachi@zabbix:~$ ssh-copy-id -i /home/itachi/.ssh/id_rsa.pub itachi@192.168.85.143 /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/itachi/.ssh/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 itachi@192.168.85.143's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'itachi@192.168.85.143'" and check to make sure that only the key(s) you wanted were added.
itachi@zabbix-mysql:~$ ls -lR .ssh/
.ssh/:
total 4
-rw------- 1 itachi itachi 395 Dec 5 17:23 authorized_keys # 溝通 key
itachi@zabbix:~$ ssh itachi@192.168.85.143 # 免密碼(Server > Client),root 是無法的
- 取得連結
- X
- 以電子郵件傳送
- 其他應用程式
留言
張貼留言