使用Xshell密鑰認證機制遠程登入Linux

來源:互聯網
上載者:User

標籤:xshell   centos   linux   遠程登入   

1、開啟Xshell介面,中文介面方便操作,功能表列:工具——建立使用者密鑰產生嚮導650) this.width=650;" src="/e/u261/themes/default/images/spacer.gif" style="border:1px solid rgb(221,221,221);background-position:50% 50%;" alt="spacer.gif" />

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/5B/23/wKiom1T_96Lh0MukAAGmLnY_6Ek825.jpg" style="float:none;" title="1.jpg" alt="wKiom1T_96Lh0MukAAGmLnY_6Ek825.jpg" />


2、密鑰類型選擇RSA,密鑰長度選擇2048位,單擊下一步繼續;

650) this.width=650;" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/5B/1D/wKioL1T_-MjzbCamAAF6cYIAgDQ459.jpg" title="2.jpg" style="float:none;" alt="wKioL1T_-MjzbCamAAF6cYIAgDQ459.jpg" />


3、很快產生公開金鑰對,單擊下一步繼續;

650) this.width=650;" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />650) this.width=650;" src="http://s3.51cto.com/wyfs02/M01/5B/24/wKiom1T_97KiVbm3AAGPOY4cPVU817.jpg" title="3.jpg" style="float:none;" alt="wKiom1T_97KiVbm3AAGPOY4cPVU817.jpg" />


4、密鑰名稱可以自訂,起一個自己理解的名稱,或者保持預設,輸入祕密金鑰加密的密碼,用於遠程登入;

650) this.width=650;" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />650) this.width=650;" src="http://s3.51cto.com/wyfs02/M01/5B/1D/wKioL1T_-NiQMBAnAAFKcljXk48378.jpg" title="4.jpg" style="float:none;" alt="wKioL1T_-NiQMBAnAAFKcljXk48378.jpg" />


5、將產生的公開金鑰複製一份,或儲存為檔案,完成密鑰產生。

650) this.width=650;" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/5B/1D/wKioL1T_-OHwEmzFAAH2z5ENGW4930.jpg" title="5.jpg" style="float:none;" alt="wKioL1T_-OHwEmzFAAH2z5ENGW4930.jpg" />


6、複製產生的公開金鑰到遠程linux裡面 /root/.ssh/authorized_keys 檔案中。如果沒有.ssh目錄,需要自己建立一個,並更改目錄許可權為700

[[email protected] ~]# mkdir /root/.ssh
[[email protected] ~]# chmod 700 /root/.ssh/

[[email protected] ~]# vi /root/.ssh/authorized_keys

粘貼公開金鑰的內容,儲存退出。


使用者產生的密鑰在功能表列:工具——使用者密鑰管理者 裡面儲存,可以查看屬性;

650) this.width=650;" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/5B/24/wKiom1T_98yibpbHAAGXzYA4OLc296.jpg" title="6.jpg" style="float:none;" alt="wKiom1T_98yibpbHAAGXzYA4OLc296.jpg" />


7、關閉遠程linux防火牆,千萬不要漏掉這一部分;

永久關閉selinux

 #vi /etc/selinux/config        #修改selinux的設定檔

更改“SELINUX=enforcing”為 SELINUX=disabled   儲存退出。

[[email protected] ~]# /usr/sbin/sestatus -v        #查看selinux的狀態命令
SELinux status:                 disabled

關閉防火牆

[[email protected] ~]# iptables -F                                #清空防火牆配置
[[email protected] ~]# /etc/init.d/iptables save          #清空防火牆配置後,記得儲存
iptables:將防火牆規則儲存到 /etc/sysconfig/iptables:     [確定]


8、建立一個視窗,名稱寫一個方便標示的,主機填寫遠程linux的ip地址;

650) this.width=650;" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/5B/1D/wKioL1T_-PSTpRvXAAH6jfBmnQ4545.jpg" title="7.jpg" style="float:none;" alt="wKioL1T_-PSTpRvXAAH6jfBmnQ4545.jpg" />


9、點擊左側使用者身分識別驗證,方法下拉式功能表裡面選擇Public Key,使用者名稱為root,使用者密鑰下拉式功能表選擇之前產生的密鑰,或者瀏覽裡面選擇,密碼填寫產生密鑰時設定的密碼,點擊串連就可以遠端存取linux了。

650) this.width=650;" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/5B/24/wKiom1T_99ujKLdaAAGE8ObKtx8179.jpg" title="8.jpg" style="float:none;" alt="wKiom1T_99ujKLdaAAGE8ObKtx8179.jpg" />


10、Xshell密鑰登入後介面和普通密碼登入一樣,可以查看登入日誌查詢是通過密鑰認證登入的。

日誌cat /var/log/secure    

Mar 11 20:25:29 localhost sshd[1952]: Accepted publickey for root from 192.168.20.1 port 53029 ssh2

Mar 11 20:25:29 localhost sshd[1952]: pam_unix(sshd:session): session opened for user root by (uid=0)

Accepted publickey說明是以密鑰身份登陸進來的。


本文出自 “模範生的學習部落格” 部落格,請務必保留此出處http://8802265.blog.51cto.com/8792265/1619390

使用Xshell密鑰認證機制遠程登入Linux

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.