Linux SSH無交互式訪問配置

環境準備兩臺Linux服務器:

  1. 準備一臺SSH服務端(系統環境centos6.5,ip地址192.168.100.100)

  2. 準備一臺SSH客戶端(系統環境centos6.5,ip地址192.168.100.101)

1.檢查是否安裝SSH軟件包

[root@nfsserver ~]# rpm -qa openssh-server openssl
openssh-server-5.3p1-94.el6.x86_64
openssl-1.0.1e-15.el6.x86_64

2.啓動SSH服務

[root@nfsserver ~]# /etc/init.d/sshd start

3.創建密鑰對

[root@nfsserver ~]# 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:
94:89:72:48:48:bb:89:cc:00:af:c0:69:e4:e8:13:5f root@nfsserver
The key's randomart p_w_picpath is:
+--[ RSA 2048]----+
|.o...            |
|*.oo . . o       |
|+*o oEo +        |
|Booo.o .         |
|o=o.    S        |
|  .              |
|                 |
|                 |
|                 |
+-----------------+

4.拷貝公鑰至客戶端

[root@Server ~]# ssh-copy-id -i .ssh/id_dsa.pub [email protected]

The authenticity of host '192.168.100.101 (192.168.100.101)' can't be established.

RSA key fingerprint is 5d:1b:b2:67:84:23:83:f9:59:3b:bd:91:b5:8f:c2:a9.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added '192.168.100.101' (RSA) to the list of known hosts.

[email protected]'s password:

Now try logging into the machine, with "ssh '[email protected]'", and check in:


  .ssh/authorized_keys


to make sure we haven't added extra keys that you weren't expecting.


5.測試登錄,無需密碼直接登錄客戶端

[root@Server ~]# ssh [email protected]


6.ssh-copy-id非22端口的使用方法

[root@Server ~]# ssh-copy-id -i  /root/.ssh/id_rsa.pub  '-p 端口號 [email protected]'


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章