15.6. OpenSSH 用户配置

  1. 创建本地私钥和公钥,通过执行
              [root@deep] /#su admin
              [admin@deep /]$ssh-keygen
              
    结果应该看起来像下面的例子
    
              
              Initializing random number generator...
              Generating p:  ............................++ (distance 430)
              Generating q:  ......................++ (distance 456)
              Computing the keys...
              Testing the keys...
              Key generation complete.
              Enter file in which to save the key (/home/admin/.ssh/identity): [Press Enter]
              Enter passphrase: 
              Enter the same passphrase again: 
              Your identification has been saved in /home/admin/.ssh/identity.
              Your public key is:
              1024 37 14937757511251955533691120318477293862290049394715136511145806108870001764378494676831297577843158532
              2723612061006231460440536487184367748423324091941848098890786099717524446977589647127757030728779973708569993
              017043141563536333068888944038178461608592483844590202154102756903055846534063365635584899765402181 
              
              admin@deep.openna.com
              Your public key has been saved in /home/admin/.ssh/identity.pub
              

    Note: 如果您有多个帐户,您可能想为每个帐户创建一个单独的密钥。 您可能想要为以下内容创建单独的密钥:

    • 您的邮件服务器

    • 您的 Web 服务器

    • 您的 GW 服务器

    这允许您限制这些服务器之间的访问,例如,不允许邮件帐户访问您的 Web 帐户或 GW 中的机器。 这在您的任何身份验证密钥因任何原因泄露的情况下,增强了整体安全性。

  2. 复制您的本地公钥identity.pub/home/admin/.ssh远程目录,例如,命名为authorized_keys.

    Tip: 复制文件的一种方法是使用 ftp 命令,或者您可能需要通过电子邮件将您的公钥发送给系统管理员。 只需包含以下内容即可~/.ssh/identity.pub文件在消息中。

您可能出于各种原因需要更改您的密码短语,并且可以随时通过使用 ssh-keygen 的 -p 选项来执行此操作。 要更改密码短语,请使用命令
          [root@deep] /#su admin
          [admin@deep /]$ssh-keygen -p
          

          Enter file key is in /home/admin/.ssh/identity: [Press ENTER]
          Enter old passphrase:
          Key has comment 'admin@deep.openna.com'
          Enter new passphrase:
          Enter the same passphrase again:
          Your identification has been saved with the new passphrase.