欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

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

需求描述:
192.168.31.10服務(wù)器的yunwei賬號,想要免密登陸到192.168.31.15服務(wù)器上。
直接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、復(fù)制密鑰到15服務(wù)器

[yunwei@docker01 .ssh]$ ssh-copy-id root@192.168.31.15		復(fù)制密鑰到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”。
當(dāng)使用 RSA CA 密鑰簽署證書時,此標(biāo)志還可用于指定所需的簽名類型??捎玫?RSA 簽名變體是“ssh-rsa”(SHA1 簽名,不推薦)、“rsa-sha2-256”和“rsa-sha2-512”(默認(rèn)值)

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

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

總結(jié):

就三個命令

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

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

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

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

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

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

相關(guān)文章

  • Linux Windows下設(shè)置定時執(zhí)行任務(wù)的方法

    Linux Windows下設(shè)置定時執(zhí)行任務(wù)的方法

    這篇文章主要介紹了Linux、windows下 設(shè)置定時執(zhí)行任務(wù)的方法,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價值,需要的朋友可以參考下
    2019-09-09
  • LAMP架構(gòu)系統(tǒng)服務(wù)搭建過程詳解

    LAMP架構(gòu)系統(tǒng)服務(wù)搭建過程詳解

    這篇文章主要為大家詳細(xì)介紹了LAMP架構(gòu)系統(tǒng)服務(wù)搭建過程,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-02-02
  • CentOS 6.5編譯安裝Nginx 1.10.2+MySQL 5.5.52+PHP5.5.38

    CentOS 6.5編譯安裝Nginx 1.10.2+MySQL 5.5.52+PHP5.5.38

    這篇文章主要介紹了CentOS 6.5編譯安裝Nginx 1.10.2+MySQL 5.5.52+PHP5.5.38,需要的朋友可以參考下
    2017-02-02
  • linux查看防火墻狀態(tài)與開啟關(guān)閉命令詳解

    linux查看防火墻狀態(tài)與開啟關(guān)閉命令詳解

    linux查看防火墻狀態(tài)與開啟關(guān)閉命令常用的有以下兩種方式,大家可以參考一下
    2018-03-03
  • linux如何通過crontab命令定時執(zhí)行shell腳本

    linux如何通過crontab命令定時執(zhí)行shell腳本

    為保障網(wǎng)安測試活動的順利進行,需要設(shè)置Linux服務(wù)器上服務(wù)的定時啟停,本文介紹了通過crontab實現(xiàn)服務(wù)定時啟停的方法,包括檢查crontab安裝、編寫啟停腳本、創(chuàng)建定時任務(wù)、日志記錄,以及問題解決方案,通過crontab-e命令編輯定時任務(wù)
    2024-10-10
  • Linux下安裝Oracle(CentOS-Oracle 12c)的方法

    Linux下安裝Oracle(CentOS-Oracle 12c)的方法

    這篇文章主要介紹了Linux下安裝Oracle(CentOS-Oracle 12c)的方法,本文實例講解,介紹的非常詳細(xì),具有參考借鑒價值,感興趣的朋友一起看看吧
    2016-11-11
  • Linux修改dmesg輸出的日志級別的步驟詳解

    Linux修改dmesg輸出的日志級別的步驟詳解

    要修改 /proc/sys/kernel/printk 文件的內(nèi)容以更改 dmesg 輸出的級別,可以通過命令行進行操作,這個文件包含四個值,分別代表內(nèi)核消息的不同級別,本文給大家介紹了Linux修改dmesg輸出的日志級別的步驟,需要的朋友可以參考下
    2024-07-07
  • vsftp上傳553 Could not create file錯誤解決

    vsftp上傳553 Could not create file錯誤解決

    本篇文章給大家分享了在vsftp上傳文件的時候出現(xiàn)了553 Could not create file錯誤,針對這個錯誤我們給出了解決辦法,一起學(xué)習(xí)下。
    2017-12-12
  • linux下的ssh命令及sshd服務(wù)詳解

    linux下的ssh命令及sshd服務(wù)詳解

    這篇文章主要介紹了linux下的ssh命令及sshd服務(wù),具有很好的參考價值,希望杜大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-06-06
  • centos 6.5下修改SSH端口及禁用root遠(yuǎn)程登錄的方法

    centos 6.5下修改SSH端口及禁用root遠(yuǎn)程登錄的方法

    Linux各發(fā)行版中SSH端口默認(rèn)為22,如果正式做站或其它用途,為了提高安全性就需要修改掉默認(rèn)的SSH端口號,防止被有心人窮舉密碼。這篇文章主要給大家介紹了在centos 6.5系統(tǒng)下修改SSH端口及禁用root遠(yuǎn)程登錄的方法,需要的朋友可以參考借鑒,下面來一起看看吧。
    2017-02-02

最新評論