ssh中的-i是什麼意思?

ssh中的-i是什麼意思?

該標籤將什麼-i添加到命令中,例如:

ssh -i path-to-pem-file ubuntu@ip-address

答案1

從線上說明頁:

-i identity_file
             Selects a file from which the identity (private key) for public
             key authentication is read.  The default is ~/.ssh/identity for
             protocol version 1, and ~/.ssh/id_dsa, ~/.ssh/id_ecdsa,
             ~/.ssh/id_ed25519 and ~/.ssh/id_rsa for protocol version 2.
             Identity files may also be specified on a per-host basis in the 
             configuration file.  It is possible to have multiple -i options
             (and multiple identities specified in configuration files).  
             If no certificates have been explicitly specified by the
             CertificateFile directive, ssh will also try to load certificate 
             information from the filename obtained by appending -cert.pub to 
             identity filenames.

基本上,它告訴 SSH 命令查看目標伺服器上進行身份驗證所需的金鑰檔案。如果您使用金鑰身份驗證並獲得了證書,則您需要在此處指定它。如果您使用普通密碼驗證,請忽略該選項。

此外,對於未來,用谷歌搜尋這樣的東西會更容易。您將花費更少的精力,並且更快地獲得答案。

答案2

來自手冊頁

-i 身分文件

   Selects a file from which the identity (private key) for public
   key authentication is read.  The default is ~/.ssh/identity for
   protocol version 1, and ~/.ssh/id_dsa, ~/.ssh/id_ecdsa,
   ~/.ssh/id_ed25519 and ~/.ssh/id_rsa for protocol version 2.
   Identity files may also be specified on a per-host basis in the
   configuration file.  It is possible to have multiple -i options
   (and multiple identities specified in configuration files).  If
   no certificates have been explicitly specified by the
   CertificateFile directive, ssh will also try to load certificate
   information from the filename obtained by appending -cert.pub to
   identity filenames.

相關內容