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 命令查看您在目标服务器上进行身份验证所需的密钥文件。如果您使用密钥身份验证并且已提供证书,则您需要在此处指定它。如果您使用普通密码身份验证,请忽略该选项。

此外,未来使用 Google 搜索此类信息将变得更加容易。您将花费更少的精力,并能更快地获得答案。

答案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.

相关内容