1. 程式人生 > >1.6 SSH免密登入

1.6 SSH免密登入

第1章 環境安裝配置

1.6 SSH免密登入

1、XShell的一個技巧

當多臺虛擬機器需要執行相同命令時,可以單擊XShell右下角的“三條橫槓”按鈕,選擇“全部會話”,這時XShell下方的輸入框將顯示提示“傳送文字到當前XShell視窗的全部會話”

這裡寫圖片描述

比如在XShell下方輸入框輸入data命令

這裡寫圖片描述

回車後,將該date命令同時傳送到node1、node2和node3。這時可以看到其他兩個會話標籤多了個歎號提示符。

這裡寫圖片描述 
檢視node2執行情況 
這裡寫圖片描述

 
查詢node3執行情況 
這裡寫圖片描述

2、生成RSA祕鑰對

在XShell下方輸入框中輸入命令ssh-keygen -t rsa,然後回車執行。再回車3次,即可生成RSA祕鑰對

這裡寫圖片描述

這裡寫圖片描述

這裡寫圖片描述

檢視金鑰對檔案


      
  1. [root @node1 ~] # ls .ssh
  2. id_rsa id_rsa.pub
  • 1
  • 2
  • id_rsa:私鑰
  • id_rsa.pub:公鑰-

3、將每個節點的公鑰拷貝到authorized_keys

可以通過命令ssh-copy-id,將本機公鑰複製到其他節點的authorized_keys目錄,這樣本機即可免祕鑰登入其他節點。 
為了操作方便,我們通過XShell執行下方輸入框執行命令即可:

ssh-copy-id node1
      
  • 1

按照提示輸入“yes”和密碼,即可將node1的公鑰複製到node1、node2和node3節點。(複製本機,可以實現免密登入本機)

然後再通過XShell分別執行:


      
  1. ssh- copy- id node2
  2. ssh- copy- id node3
  • 1
  • 2

通過XShell執行三條ssh-copy-id命令,實際上就是分別在node1、node2和node3節點執行。下面是命令執行資訊: 
(1)node1 
ssh-copy-id node1 
ssh-copy-id node2 
ssh-copy-id node3


      
  1. [[email protected] ~] # ssh-copy-id node1
  2. The authenticity of host 'node1 (192.168.80.131)' can't be established.
  3. ECDSA key fingerprint is e2: 9a: 7d: 70: 25: 24: 45: 11: 97: 12: 35:e0: 45: 4c: 64: 31.
  4. Are you sure you want to continue connecting (yes/no)? yes
  5. /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
  6. /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
  7. [email protected] 's password:
  8. Number of key(s) added: 1
  9. Now try logging into the machine, with: "ssh 'node1'"
  10. and check to make sure that only the key(s) you wanted were added.
  11. [[email protected] ~] # ssh-copy-id node2
  12. The authenticity of host 'node2 (192.168.80.132)' can't be established.
  13. ECDSA key fingerprint is e2: 9a: 7d: 70: 25: 24: 45: 11: 97: 12: 35:e0: 45: 4c: 64: 31.
  14. Are you sure you want to continue connecting (yes/no)? yes
  15. /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
  16. /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
  17. [email protected] 's password:
  18. Number of key(s) added: 1
  19. Now try logging into the machine, with: "ssh 'node2'"
  20. and check to make sure that only the key(s) you wanted were added.
  21. [[email protected] ~] # ssh-copy-id node3
  22. The authenticity of host 'node3 (192.168.80.133)' can't be established.
  23. ECDSA key fingerprint is e2: 9a: 7d: 70: 25: 24: 45: 11: 97: 12: 35:e0: 45: 4c: 64: 31.
  24. Are you sure you want to continue connecting (yes/no)? yes
  25. /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
  26. /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
  27. [email protected] 's password:
  28. Number of key(s) added: 1
  29. Now try logging into the machine, with: "ssh 'node3'"
  30. and check to make sure that only the key(s) you wanted were added.
  31. [[email protected] ~] #
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40

(2)node2 
ssh-copy-id node1 
ssh-copy-id node2 
ssh-copy-id node3


      
  1. [[email protected] ~] # ssh-copy-id node1
  2. The authenticity of host 'node1 (192.168.80.131)' can't be established.
  3. ECDSA key fingerprint is e2: 9a: 7d: 70: 25: 24: 45: 11: 97: 12: 35:e0: 45: 4c: 64: 31.
  4. Are you sure you want to continue connecting (yes/no)? yes
  5. /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
  6. /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
  7. [email protected] 's password:
  8. Number of key(s) added: 1
  9. Now try logging into the machine, with: "ssh 'node1'"
  10. and check to make sure that only the key(s) you wanted were added.
  11. [[email protected] ~] # ssh-copy-id node2
  12. The authenticity of host 'node2 (192.168.80.132)' can't be established.
  13. ECDSA key fingerprint is e2: 9a: 7d: 70: 25: 24: 45: 11: 97: 12: 35:e0: 45: 4c: 64: 31.
  14. Are you sure you want to continue connecting (yes/no)? yes
  15. /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
  16. /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
  17. [email protected] 's password:
  18. Number of key(s) added: 1
  19. Now try logging into the machine, with: "ssh 'node2'"
  20. and check to make sure that only the key(s) you wanted were added.
  21. [[email protected] ~] # ssh-copy-id node3
  22. The authenticity of host 'node3 (192.168.80.133)' can't be established.
  23. ECDSA key fingerprint is e2: 9a: 7d: 70: 25: 24: 45: 11: 97: 12: 35:e0: 45: 4c: 64: 31.
  24. Are you sure you want to continue connecting (yes/no)? yes
  25. /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
  26. /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
  27. [email protected] 's password:
  28. Number of key(s) added: 1
  29. Now try logging into the machine, with: "ssh 'node3'"
  30. and check to make sure that only the key(s) you wanted were added.
  31. [[email protected] ~] #
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40

(3)node3 
ssh-copy-id node1 
ssh-copy-id node2 
ssh-copy-id node3


      
  1. [[email protected] ~] # ssh-copy-id node1
  2. The authenticity of host 'node1 (192.168.80.131)' can't be established.
  3. ECDSA key fingerprint is e2: 9a: 7d: 70: 25: 24: 45: 11: 97: 12: 35:e0: 45: 4c: 64: 31.
  4. Are you sure you want to continue connecting (yes/no)? yes
  5. /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
  6. /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
  7. [email protected] 's password:
  8. Number of key(s) added: 1
  9. Now try logging into the machine, with: "ssh 'node1'"
  10. and check to make sure that only the key(s) you wanted were added.
  11. [[email protected] ~] # ssh-copy-id node2
  12. The authenticity of host 'node2 (192.168.80.132)' can't be established.
  13. ECDSA key fingerprint is e2: 9a: 7d: 70: 25: 24: 45: 11: 97: 12: 35:e0: 45: 4c: 64: 31.
  14. Are you sure you want to continue connecting (yes/no)? yes
  15. /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
  16. 相關推薦

    centos 7 ssh密碼登入(補充1.6 SSH登入

    參考(十分詳細):http://blog.csdn.net/newstruts/article/details/46424191 目的 在搭建Linux叢集服務的時候,主伺服器需要啟動從伺服器的服務,如果通過手動啟動,叢集內伺服器幾臺還好,要是像阿里1000臺

    1.6 SSH登入

    第1章 環境安裝配置 1.6 SSH免密登入 1、XShell的一個技巧 當多臺虛擬機器需要執行相同命令時,可以單擊XShell右下角的“三條橫槓”按鈕,選擇“全部會話”,這時XShell下方的輸入框將顯示提示“傳送文字到

    expect一鍵實現集群ssh登入

    scriptexpect具有非交互式功能yum -y install expectmkpasswd -l 20 #<==生成隨機字符串,-l參數指定生成字符串的長度非交互密鑰分發添加用戶(所有機器)useradd jiege1echo 123456|passwd --stdin jiege1id j

    linux設定ssh登入ssh-copy-id命令

    linux系統配置免密碼的方式: 1:ssh-keygen -t rsa ssh-keygen -t dsa 生成金鑰 2:ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected] # 接下來一路回車到底

    配置Linux ssh 登入

    linux 常用的ssh登入方式主要有兩種:密碼登入和證書登入 有兩臺機器,機器A和機器B: 如從A登入機器B: 密碼登入方式:在機器A上操作 ssh [email protected]機器B的ip 提示輸入密碼,登入成功! 免密登入方式:在機器A上操作 ssh [em

    SSH 登入配置和遠端登入伺服器

    生成SSH私鑰和公鑰 ssh-keygen -t rsa 手動建立一個 authorized_keys檔案 touch ~/.ssh/authorized_keys 公鑰檔案內容複製到authorized_keys檔案裡面 cat ~/.ssh/id_rsa.pub

    自動設定ssh登入指令碼

    自動設定ssh免密登入指令碼 `#!/bin/bash #yum安裝expect yum -y install expect #PWD_1是登陸密碼,可以自己設定 PWD_1=123456 ips=$(cat /etc/hosts |grep -v “::” | grep -v “127

    配置ssh登入伺服器

    當前伺服器環境為ubantu 14.04 一、本地 ①生成id_rsa   id_rsa.pub ssh-keygen -t rsa -C "[email protected]" ssh -T [email protected] 碼雲生成ssh ke

    Linux的SSH登入認證過程研究

    一、先看下SSH免密登入使用到的工具和生成的檔案 工具:ssh-keygen用於生成祕鑰檔案,其中祕鑰分為公鑰和私鑰、ssh-copy-id用於複製公鑰檔案到被控制機。 檔案:ssh-keygen生成的祕鑰檔案有兩個,放在~/.ssh/,id_rsa為私鑰、id_rsa.pub為公鑰 被控制機檔案:通過

    關於Hadoop叢集中使用SSH登入的詳細操作!

    很多時候,在我們操作不同的虛擬機器時,常常因為一些需要密碼的操作,因此,各虛擬機器之間的免密設定必不可少。那麼這篇我們就來介紹關於虛擬機器之間配置SSH免密操作的詳細流程! 準備條件:兩臺以上的虛擬機器,因為想要給大家介紹關於Hadoop叢集的搭建,所以我這邊準備了三臺虛擬機器,分別為: h

    牛逼的SSH登入-低調小熊貓的技術小黑屋

    牛逼的SSH免密登入 相逢便是緣,歡迎來到低調小熊貓的技術小黑屋我的部落格:https://aodeng.cc 我的公眾號:低調小熊貓 我的QQ群:756796932 1.生成SSH金鑰和公鑰 ssh-keygen -t rsa 會在當前目錄生成名為id_rsa的私鑰

    linux ssh登入/scp命令

    ● 生成本機的密碼(私鑰和公鑰) #一直回車下去即可(敲三下) [[email protected] ~]# ssh-key ssh-keygen ssh-keyscan [[email protected] ~]# ssh-keygen Generatin

    Centos伺服器ssh登入以及搭建私有git伺服器

    一、概述   伺服器的免密登入和git伺服器的搭建,關鍵都是要學會把自己用的機器的公鑰新增到伺服器上,讓伺服器“認識”你的電腦,從而不需要輸入密碼就可以遠端登入伺服器上的使用者   免密登入當然是登入root使用者,而搭建git伺服器需要在伺服器上建立一個git使用者。注意伺服器上每個使用者識別的公鑰存在不同

    ssh 登入設定

    1. SSH的登入原理如圖所示: Client將自己的公鑰存放在Server上,追加在檔案authorized_keys中。 Server端接收到Client的連線請求後,會在authorized_keys中匹配到Client的公鑰pubKey,並生成隨機數R,用

    Hadoop叢集搭建中ssh登入

     參考: 大資料系列(3) Hadoop中的ssh無密碼登入配置 解決 Agent admitted failure to sign using the key 問題 with ssh

    三、配置SSH登入

    企業級大資料平臺Ambari搭建與管理 本節中我們將介紹Ambari叢集的SSH免密登入 1、安裝openssh-client客戶端: 此步驟中所有操作都使用“傳送鍵輸入到所有回話功能”進行配置: 安裝openssh-client客戶端 [[email 

    centos7配置ssh登入

    修改主機名和ip對映 i#修改p對映 vi /etc/hosts #修改主機名 vi /etc/sysconfig/network 重啟機器使之生效 生成公鑰和金鑰 ssh-keygen -t ras 一直回車,會在使用者目錄下生成.ssh資料夾,裡面有三

    Ubuntu16.04配置ssh登入

    參考自:https://blog.csdn.net/wenyun_kang/article/details/77413714 原材料: 安裝成功的Ubuntu系統   步驟: 1.更新軟體源(在此之前需要確保自己的linux系統可以聯網)。命令:sudo apt-get

    十四、SSH登入

                                                                SSH免密登入 1、客戶端生成公鑰、私鑰 [email protecte

    入門學習Hadoop1:VMware上搭建hadoop伺服器Centos7叢集,並設定SSH登入

    修改主機名:hostnamectl set-hostname master 檢視自己虛擬機器閘道器IP為多少 修改ip:vim /etc/sysconfig/network-scripts/ifcfg-ens32 master:192.168.187.100