最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Linux實現(xiàn)免密登錄的配置方法

 更新時間:2024年04月28日 16:37:45   作者:生產(chǎn)隊隊長  
這篇文章主要介紹了Linux實現(xiàn)免密登錄的配置方法,實現(xiàn)的效果是,當前服務器的test賬號可以免密登陸15服務器的test賬號,需要的朋友可以參考下

需求描述:
192.168.31.10服務器的yunwei賬號,想要免密登陸到192.168.31.15服務器上。
直接ssh root@192.168.31.15這樣登陸,不用輸入密碼。

實現(xiàn):
1、在10機器上,創(chuàng)建運維賬號。

[root@docker01 ~]# id yunwei				檢查yunwei賬號是否存在
id: yunwei: no such user
[root@docker01 ~]# useradd yunwei			創(chuàng)建yunwei賬號
[root@docker01 ~]# su - yunwei				切換到y(tǒng)unwei賬號
[yunwei@docker01 ~]$ pwd
/home/yunwei

2、在yunwei賬號下創(chuàng)建密鑰

[yunwei@docker01 ~]$ ssh-keygen		創(chuàng)建密鑰,一路回車
Generating public/private rsa key pair.
Enter file in which to save the key (/home/yunwei/.ssh/id_rsa):
Created directory '/home/yunwei/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/yunwei/.ssh/id_rsa.
Your public key has been saved in /home/yunwei/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:kLXaRvzgGOqF62RyGWKGUekspD39l0pudQBt1MQp3NU yunwei@docker01
The key's randomart image is:
+---[RSA 2048]----+
|  ..   +o=.o..   |
| o.   .+=.=   E  |
|++ .  +o=.       |
|oo= .o O.o       |
|..+.+.+ So.      |
| o o =o.+ .      |
|  . Bo + .       |
|   *  +          |
|    ..           |
+----[SHA256]-----+
檢查密鑰是否創(chuàng)建成功
[yunwei@docker01 ~]$ pwd
/home/yunwei
[yunwei@docker01 ~]$ ll -a
total 12
drwx------.  5 yunwei yunwei 103 Mar 25 23:18 .
drwxr-xr-x. 16 root   root   177 Mar 25 23:17 ..
-rw-r--r--.  1 yunwei yunwei  18 Mar 31  2020 .bash_logout
-rw-r--r--.  1 yunwei yunwei 193 Mar 31  2020 .bash_profile
-rw-r--r--.  1 yunwei yunwei 231 Mar 31  2020 .bashrc
drwxrwxr-x.  3 yunwei yunwei  18 Mar 25 23:17 .cache
drwxrwxr-x.  3 yunwei yunwei  18 Mar 25 23:17 .config
drwx------.  2 yunwei yunwei  38 Mar 25 23:18 .ssh
[yunwei@docker01 ~]$ cd .ssh/
[yunwei@docker01 .ssh]$ ls
id_rsa  id_rsa.pub

3、復制密鑰到15服務器

[yunwei@docker01 .ssh]$ ssh-copy-id root@192.168.31.15		復制密鑰到15機器
/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/yunwei/.ssh/id_rsa.pub"
The authenticity of host '192.168.31.15 (192.168.31.15)' can't be established.
ECDSA key fingerprint is SHA256:v3zhW/rvSt+T7QfAnIDIiHhbALRLNiLzl8Hg3TAZQCA.
ECDSA key fingerprint is MD5:cf:b8:e1:f6:a5:61:60:f0:77:aa:f3:76:ab:d2:ce:9b.
Are you sure you want to continue connecting (yes/no)? yes
/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/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@192.168.31.15's password:
Number of key(s) added: 1
Now try logging into the machine, with:   "ssh 'root@192.168.31.15'"
and check to make sure that only the key(s) you wanted were added.

4、驗證免密登陸

[yunwei@docker01 .ssh]$ ssh root@192.168.31.15
Last login: Sun Mar 26 11:21:02 2023 from 192.168.31.1

補充:優(yōu)化密鑰創(chuàng)建方式,免交互創(chuàng)建密鑰

[yunwei@docker01 .ssh]$ ssh-keygen -P '' -f id_rsa		免交互方式,創(chuàng)建密鑰
Generating public/private rsa key pair.
Your identification has been saved in id_rsa.
Your public key has been saved in id_rsa.pub.
The key fingerprint is:
SHA256:hXuSBtV1o1D1PfIyG/+iC1IFnZh8Q3NGf5eiuQ8IExQ yunwei@docker01
The key's randomart image is:
+---[RSA 2048]----+
|       EoooB=+B  |
|      .. .=o=* +o|
|      ... ..o+ o*|
|       ..+ .o + +|
|       oS oo + . |
|       .o+. . *  |
|        ...o . . |
|         . .o . .|
|            o+ ..|
+----[SHA256]-----+
[yunwei@docker01 .ssh]$ ls
id_rsa  id_rsa.pub  known_hosts

參數(shù)說明:
-t 指定要創(chuàng)建的密鑰類型
dsa | ecdsa | ecdsa-sk | ed25519 | ed25519-sk | RSA
可能的值為“dsa”、“ecdsa”、“ecdsa-sk”、“ed25519”、“ed25519-sk”或“rsa”。
當使用 RSA CA 密鑰簽署證書時,此標志還可用于指定所需的簽名類型??捎玫?RSA 簽名變體是“ssh-rsa”(SHA1 簽名,不推薦)、“rsa-sha2-256”和“rsa-sha2-512”(默認值)

-P 密碼
提供(舊)密碼。
這里的密碼,是密鑰的密碼,不是遠程主機的密碼,隨便設置。但是,這就失去了免密登陸的意義。因為,設置了這個后,登陸遠程主機時,就必須輸入密鑰密碼。
所以,一般這個指指定為空即可。

-f 文件名
指定密鑰文件的文件名
這里的文件名,必須指定為id_rsa,不然,把密鑰推送到目標機器,依然無法實現(xiàn)免密登陸。

總結:

就三個命令

cd							進入當前賬號家目錄
ssh-keygen					連續(xù)三次回車		
ssh-copy-id 192.168.31.15	復制公鑰到hadoop104服務器,這樣,就可以免密訪問hadoop104服務器

這里用戶賬號省略,則使用當前賬號進行免密登陸
比如,當前賬號是test

ssh-copy-id 192.168.31.15 等價與 ssh-copy-id test@192.168.31.15

實現(xiàn)的效果是,當前服務器的test賬號可以免密登陸15服務器的test賬號

參考資料:https://www.cnblogs.com/dirigent/p/16636545.html 

到此這篇關于Linux實現(xiàn)免密登錄的配置方法的文章就介紹到這了,更多相關Linux免密登錄內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

相關文章

  • Centos7下編譯安裝配置Nginx+PHP+MySql環(huán)境

    Centos7下編譯安裝配置Nginx+PHP+MySql環(huán)境

    這篇文章主要介紹了Centos7下編譯安裝配置Nginx+PHP+MySql環(huán)境,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-02-02
  • linux(centos)下SVN服務器如何搭建

    linux(centos)下SVN服務器如何搭建

    linux(centos)下SVN服務器如何搭建?說到SVN服務器,想必大家都知道,可以是在LINUX下如何搭建SVN服務器呢?那么今天給大家分享一下linux(centos)搭建SVN服務器的思路!
    2015-09-09
  • linux touch,chattr指令詳解及用法

    linux touch,chattr指令詳解及用法

    這篇文章主要介紹了 linux touch,chattr指令詳解幾用法的相關資料,需要的朋友可以參考下
    2017-02-02
  • 超詳細講解Linux DHCP服務

    超詳細講解Linux DHCP服務

    這篇文章主要介紹了Linux DHCP 服務,它可以避免IP地址沖突,提高了IP地址的利用率等優(yōu)點。感興趣的小伙伴一起來學習吧
    2021-08-08
  • linux環(huán)境配置nginx導致頁面不刷新的解決方法

    linux環(huán)境配置nginx導致頁面不刷新的解決方法

    這篇文章介紹了linux環(huán)境配置nginx導致頁面不刷新的解決方法,有需要的朋友可以參考一下
    2013-09-09
  • 關于安裝LNMP集成包后上傳圖片報500錯誤的解決方法

    關于安裝LNMP集成包后上傳圖片報500錯誤的解決方法

    這篇文章主要給大家介紹了關于安裝LNMP集成包后上傳圖片報500錯誤的解決方法,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧。
    2018-01-01
  • Linux系統(tǒng)的修復模式(單用戶模式)

    Linux系統(tǒng)的修復模式(單用戶模式)

    大家好,本篇文章主要講的是Linux系統(tǒng)的修復模式(單用戶模式),感興趣的同學趕快來看一看吧,對你有幫助的話記得收藏一下,方便下次瀏覽
    2021-12-12
  • Linux中查看并刪除端口方式

    Linux中查看并刪除端口方式

    這篇文章主要介紹了Linux中查看并刪除端口方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2025-06-06
  • 在Linux系統(tǒng)下上傳項目到碼云的方法

    在Linux系統(tǒng)下上傳項目到碼云的方法

    今天小編就為大家分享一篇關于在Linux系統(tǒng)下上傳項目到碼云的方法,小編覺得內容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧
    2018-10-10
  • 使用Apache ab進行http性能測試

    使用Apache ab進行http性能測試

    這篇文章主要為大家詳細介紹了使用Apache ab進行http性能測試,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2019-12-12

最新評論

九江市| 阳城县| 卢氏县| 鄢陵县| 扎鲁特旗| 紫金县| 玉环县| 静乐县| 永和县| 当涂县| 油尖旺区| 乌兰县| 阿拉尔市| 科技| 岚皋县| 临武县| 巴塘县| 犍为县| 巨鹿县| 天祝| 化州市| 通化县| 于田县| 清涧县| 铅山县| 桃江县| 息烽县| 塔城市| 页游| 新野县| 达尔| 松滋市| 庆阳市| 海晏县| 基隆市| 新源县| 化隆| 湟源县| 苗栗县| 大同市| 吐鲁番市|