導航:首頁 > 操作系統 > linux免密碼登陸

linux免密碼登陸

發布時間:2022-10-06 08:53:01

『壹』 linux下怎樣設置ssh無密碼登錄

第1步:在本地主機中生成「密鑰對」並將公鑰傳送到遠程伺服器中:
[root@linuxprobe ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):直接敲擊回車或設置密鑰的存儲路徑
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase): 直接敲擊回車或設置密鑰的密碼
Enter same passphrase again: 再次敲擊回車或設置密鑰的密碼
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
40:32:48:18:e4:ac:c0:c3:c1:ba:7c:6c:3a:a8:b5:22 [email protected]
The key's randomart image is:
+--[ RSA 2048]----+
|+*..o . |
|*.o + |
|o* . |
|+ . . |
|o.. S |
|.. + |
|. = |
|E+ . |
|+.o |
+-----------------+

第2步:將生成好的私鑰文件傳送至遠程主機:
[root@linuxprobe ~]# ssh--id 192.168.10.20
The authenticity of host '192.168.10.20 (192.168.10.20)' can't be established.
ECDSA key fingerprint is 4f:a7:91:9e:8d:6f:b9:48:02:32:61:95:48:ed:1e:3f.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh--id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh--id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
[email protected]'s password:此處輸入遠程伺服器主機密碼
Number of key(s) added: 1
Now try logging into the machine, with: "ssh '192.168.10.20'"
and check to make sure that only the key(s) you wanted were added.

第3步:設置伺服器主機只允許密鑰驗證,拒絕傳統口令驗證方式,記得修改配置文件後保存並重啟sshd服務程序哦~:
[root@linuxprobe ~]# vim /etc/ssh/sshd_config
………………省略部分輸出信息………………
74
75 # To disable tunneled clear text passwords, change to no here!
76 #PasswordAuthentication yes
77 #PermitEmptyPasswords no
78 PasswordAuthentication no
79
………………省略部分輸出信息………………
[root@linuxprobe ~]# systemctl restart sshd

第4步:在客戶端主機嘗試登陸到服務端主機,此時無需輸入密碼口令也可直接驗證登陸成功:
[root@linuxprobe ~]# ssh 192.168.10.20
Last login: Mon Apr 13 19:34:13 2017

ssh的話你可以詳細看一下http://www.linuxprobe.com/chapter-09.html#921_sshd

『貳』 linux下怎樣設置ssh無密碼登錄

首先你要有一個無密碼的用戶。
修改ssh配置文件,步驟如下:
1)
修改 /etc/ssh/sshd_config
文件中 PermitEmptyPasswords
這個參數為yes(即允許空密碼的用戶登錄,默認是no)
2)
重啟
ssh服務,service
ssh
restart
3)
重新登錄ssh,即可無密碼登錄。

『叄』 linux下怎樣設置ssh無密碼登錄

第1步:在本地主機中生成「密鑰對」並將公鑰傳送到遠程伺服器中:
[root@linuxprobe ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):直接敲擊回車或設置密鑰的存儲路徑
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase): 直接敲擊回車或設置密鑰的密碼
Enter same passphrase again: 再次敲擊回車或設置密鑰的密碼
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
40:32:48:18:e4:ac:c0:c3:c1:ba:7c:6c:3a:a8:b5:22 [email protected]
The key's randomart image is:
+--[ RSA 2048]----+
|+*..o . |
|*.o + |
|o* . |
|+ . . |
|o.. S |
|.. + |
|. = |
|E+ . |
|+.o |
+-----------------+

第2步:將生成好的私鑰文件傳送至遠程主機:
[root@linuxprobe ~]# ssh--id 192.168.10.20
The authenticity of host '192.168.10.20 (192.168.10.20)' can't be established.
ECDSA key fingerprint is 4f:a7:91:9e:8d:6f:b9:48:02:32:61:95:48:ed:1e:3f.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh--id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh--id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
[email protected]'s password:此處輸入遠程伺服器主機密碼
Number of key(s) added: 1
Now try logging into the machine, with: "ssh '192.168.10.20'"
and check to make sure that only the key(s) you wanted were added.

第3步:設置伺服器主機只允許密鑰驗證,拒絕傳統口令驗證方式,記得修改配置文件後保存並重啟sshd服務程序哦~:
[root@linuxprobe ~]# vim /etc/ssh/sshd_config
………………省略部分輸出信息………………
74
75 # To disable tunneled clear text passwords, change to no here!
76 #PasswordAuthentication yes
77 #PermitEmptyPasswords no
78 PasswordAuthentication no
79
………………省略部分輸出信息………………
[root@linuxprobe ~]# systemctl restart sshd

第4步:在客戶端主機嘗試登陸到服務端主機,此時無需輸入密碼口令也可直接驗證登陸成功:
[root@linuxprobe ~]# ssh 192.168.10.20
Last login: Mon Apr 13 19:

『肆』 linux如何配置雙機SSH信任然後雙向免密碼登陸

一、實現原理
使用一種被稱為"公私鑰"認證的方式來進行ssh登錄。"公私鑰"認證方式簡單的解釋是:
首先在客戶端上創建一對公私鑰(公鑰文件:~/.ssh/id_rsa.pub;私鑰文件:~/.ssh/id_rsa),然後把公鑰放到伺服器上(~/.ssh/authorized_keys),自己保留好私鑰。當ssh登錄時,ssh程序會發送私鑰去和伺服器上的公鑰做匹配。如果匹配成功就可以登錄了。
二、實驗環境
A機:TS-DEV/10.0.0.163
B機:CS-DEV/10.0.0.188
三、Linux/Unix雙機建立信任
3.1
在A機生成證書
在A機root用戶下執行ssh-keygen命令,在需要輸入的地方,直接回車,生成建立安全信任關系的證書。
#
ssh-keygen
-t
rsa
注意:在程序提示輸入passphrase時直接輸入回車,表示無證書密碼。
上述命令將生成私鑰證書id_rsa和公鑰證書id_rsa.pub,存放在用戶家目錄的.ssh子目錄中。
3.2
查看~/.ssh生成密鑰的文件
#
cd
~/.ssh
#
ll
3.3
A對B建立信任關系
將公鑰證書id_rsa.pub復制到機器B的root家目錄的.ssh子目錄中,同時將文件名更換為authorized_keys,此時需要輸入B機的root用戶密碼(還未建立信任關系)。建立了客戶端到伺服器端的信任關系後,客戶端就可以不用再輸入密碼,就可以從伺服器端拷貝數據了。
#
scp
-r
id_rsa.pub
10.0.0.188:/root/.ssh/authorized_keys
3.4
B對A建立信任關系
在B機上執行同樣的操作,建立B對A的信任關系。
#
ssh-keygen
-t
rsa
#
cd
~/.ssh/
#
ll
#
scp
-r
id_rsa.pub
10.0.0.163:/root/.ssh/authorized_keys
如果想讓B,C同時可以scp不輸入密碼,傳輸A中的數據;
則要把B、C的公鑰都給
A;
操作步驟:把兩機器的id_rsa.pub中的數據都拷貝到A的/root/.ssh/authorized_keys文件中,一行表示一條;
A:
scp
-r
id_rsa.pub
10.0.0.163:/root/.ssh/authorized_keys
B:
scp
-r
id_rsa.pub
10.0.0.188:/root/.ssh/authorized_keys
測試
ssh
[email protected]
'hostname'
///
ssh
[email protected]
'hostname'
如果連接反應慢,請修改以下兩參數
/etc/ssh/sshd_config
GSSAPIAuthentication
no
UseDNS
no
然後重啟service
sshd
restart

『伍』 為何linux系統設置免密碼登錄之後,還需要密碼

一、設置了免密碼登陸但是還是需要輸入密碼: 許可權保證:1、authorized-keys 的許可權為 600 2、home、賬戶所在的目錄如hadoop、.ssh這三個文件的許可權都必須設置為7...

『陸』 怎麼設置兩台linux的免密碼登陸

首先你要有一個無密碼的用戶。
修改ssh配置文件,步驟如下:1) 修改 /etc/ssh/sshd_config 文件中 PermitEmptyPasswords 這個參數為yes(即允許空密碼的用戶登錄,默認是no)2) 重啟 ssh服務,service ssh restart3) 重新登錄ssh,即可無密碼登錄。</ol>

『柒』 linux下怎樣設置ssh無密碼登錄

  1. 首先你要有一個無密碼的用戶。

  2. 修改ssh配置文件,步驟如下:

    1) 修改/etc/ssh/sshd_config 文件中PermitEmptyPasswords 這個參數為yes(即允許空密碼的用戶登錄,默認是no)

    2) 重啟 ssh服務,service ssh restart

    3) 重新登錄ssh,即可無密碼登錄。

『捌』 如何讓linux自動登錄,不需輸入密碼

linux開機登錄方式有兩種,一種是文本模式,一種是桌面模式(KDE/GNOME)
在文本模式下,如何設置,使得機器重啟後無需輸入用戶名和密碼就能進入命令行。
linux開機完成init.d下的各種初始化服務之後,會運行/usr/bin/login程序,然後等待用戶輸入用戶名和密碼,如何避免輸入用戶名和密碼呢

  1. 在/usr/bin下建立一個腳步:autologin文件
    創建autologin文件 vim autologin
    輸入:!/bin/bash
    /bin/login -f root
    wq! 保存退出

  2. 修改文件/etc/event.d/tty1 (默認最後載入的是/usr/bin/login程序,將其修改為/usr/bin/autologin)
    exec /sbin/getty/ -n -l /usr/autologin 38400 tty1

  3. 保存退出。重啟系統,即可實現無需輸入用戶實現自動以root用戶登錄

『玖』 如何在linux中如何配置ssh免密碼登錄

首先需要在伺服器端設置/etc/ssh/sshd_config
# vim /etc/ssh/sshd_config
修改如下兩行為yes。其實大多數情況下不用修改,默認就是yes。
RSAAuthentication yes
PubkeyAuthentication yes
(1) 如果客戶機和伺服器都是Linux機器,那麼我們使用下面的方法:(後面第2節會提到怎麼在Windows下使用Putty生成密鑰對)
我們需要在客戶端生成RSA密鑰對。使用ssh-keygen命令:
# ssh-keygen -t rsa
參數t的意思是type,後面跟著加密類型,這里我們是rsa。
然後會提示你輸入密鑰保存完成文件名,這里我們需要使用默認的id_rsa,之後才能正常才能登錄。如果你生成的密鑰作為其他用處,那麼可以命名為其他名稱:
Generating public/private rsa key pair.
Enter file in which to save the key (/home/cake/.ssh/id_rsa):
之後會提示你輸入一個passphrase,我們這里可以留空,這樣我們登錄的時候就不許輸入密碼。
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
然後會提示你密鑰生成成功。這是你的私鑰保存為~/.ssh/id_rsa,你的公鑰是~/.ssh/id_rsa.pub
我們現在需要做的是,把id_rsa.pub的內容,添加的伺服器端的~/.ssh/autherized_keys文件最後。
你可以把這個文件上傳到伺服器端,然後使用命令:
# cat id_rsa.pub >> ~/.ssh/autherized_keys
到這里就完成了。
(2) 在Windows下使用Putty生成密鑰對:
Putty的安裝目錄下有個puttygen.exe程序,我們運行這個程序。
之後點擊Generate,開始生成密鑰對。我們需要根據提示,在指定方框內隨機滑動滑鼠。這是為了根據滑鼠軌跡,產生一些隨機數據。
之後生成結束,我們點擊Save Private Key將私鑰存放在某個目錄中。然後賦值最上面文本框中的全部內容,粘貼到Linux伺服器端的autherized_key的最後。
我們現在可以關閉這個小程序。
現在打開Putty,在左邊的選項中,選擇Conneciton–SSH–Auth,在Private key file for authentication中,選擇剛才保存的私鑰路徑就可以了。
到此位置,Putty也可以不用密碼登錄了。

閱讀全文

與linux免密碼登陸相關的資料

熱點內容
怎麼消除安卓的系統通知 瀏覽:477
程序員3萬4是稅後嗎 瀏覽:867
javagui窗口 瀏覽:521
風月片網站動漫 瀏覽:289
電影拉幫套 瀏覽:745
鴉王電影國語版 瀏覽:600
造機甲的黑科技小說 瀏覽:779
歐美在線觀看網站 瀏覽:385
python整蠱代碼大全 瀏覽:458
電影 中國 飛機 瀏覽:103
畫江湖推倒常宣靈小說 瀏覽:158
java表格居中 瀏覽:404
能來回穿梭現代和民國的小說 瀏覽:830
法國版未刪 瀏覽:755
java中字元串輸入 瀏覽:185
可愛女友糖糖圓圓小詩 瀏覽:272
如何在雲南交投app辦etc 瀏覽:829
尺度大的男同志電影 瀏覽:925
主角為秦霄的穿越小說 瀏覽:707