Linux下無需密碼遠端登入

Linux下無需密碼遠端登入

我是 Linux 作業系統的新手。我正在使用紅帽 Linux。

誰能告訴我如何使用遠端服務登入遠端電腦而不提供密碼?

Linux 中是否有任何命令或我必須為其編寫「C」程式碼?

答案1

您不必編寫程式碼。

首先透過以下方式產生您的金鑰對

ssh-keygen

其次,使用 ssh-copy-id 分發您的公鑰

ssh-copy-id username@remote-machine

請注意,執行此命令時需要提供密碼。之後就可以不用密碼登入遠端機器了。

以下是手冊頁中命令的一些解釋:

ssh 密鑰產生器

 ssh-keygen generates, manages and converts authentication keys for
 ssh(1).  ssh-keygen can create RSA keys for use by SSH protocol version 1
 and DSA, ECDSA or RSA keys for use by SSH protocol version 2.  The type
 of key to be generated is specified with the -t option.  If invoked with-
 out any arguments, ssh-keygen will generate an RSA key for use in SSH
 protocol 2 connections.

ssh 複製 ID

 ssh-copy-id  is  a  script  that  uses  ssh  to  log into a remote machine
 and append the indicated identity file to that machine's
 ~/.ssh/authorized_keys file.

答案2

查看 ssh,它可以使用公鑰對來驗證登錄,您將私有部分儲存在本機電腦上,將公共部分儲存在遠端電腦上。

相關內容