亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

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

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

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

實(shí)現(xiàn):
1、在10機(jī)器上,創(chuàng)建運(yùn)維賬號(hào)。

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

2、在yunwei賬號(hào)下創(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機(jī)器
/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、驗(yàn)證免密登陸

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

補(bǔ)充:優(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ù)說(shuō)明:
-t 指定要?jiǎng)?chuàng)建的密鑰類型
dsa | ecdsa | ecdsa-sk | ed25519 | ed25519-sk | RSA
可能的值為“dsa”、“ecdsa”、“ecdsa-sk”、“ed25519”、“ed25519-sk”或“rsa”。
當(dāng)使用 RSA CA 密鑰簽署證書(shū)時(shí),此標(biāo)志還可用于指定所需的簽名類型??捎玫?RSA 簽名變體是“ssh-rsa”(SHA1 簽名,不推薦)、“rsa-sha2-256”和“rsa-sha2-512”(默認(rèn)值)

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

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

總結(jié):

就三個(gè)命令

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

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

ssh-copy-id 192.168.31.15 等價(jià)與 ssh-copy-id test@192.168.31.15

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

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

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

相關(guān)文章

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

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

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

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

    這篇文章主要為大家詳細(xì)介紹了LAMP架構(gòu)系統(tǒng)服務(wù)搭建過(guò)程,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    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)與開(kāi)啟關(guān)閉命令詳解

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

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

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

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

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

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

    Linux修改dmesg輸出的日志級(jí)別的步驟詳解

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

    vsftp上傳553 Could not create file錯(cuò)誤解決

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

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

    這篇文章主要介紹了linux下的ssh命令及sshd服務(wù),具有很好的參考價(jià)值,希望杜大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    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端口號(hào),防止被有心人窮舉密碼。這篇文章主要給大家介紹了在centos 6.5系統(tǒng)下修改SSH端口及禁用root遠(yuǎn)程登錄的方法,需要的朋友可以參考借鑒,下面來(lái)一起看看吧。
    2017-02-02

最新評(píng)論