假设需要为两台主机建立ssh key以便抓取、更新代码,主机A:111.111.111.111,主机B:222.222.222.222。
  首先,用两个账户(hostA@email.comhostB@email.com)生成两个ssh,分别存到不同位置,例如:
  # 主机A的存在/c/user/.ssh/id_rsa
  ssh-keygen -t rsa –C “hostA@email.com
  # 主机B的存在/c/user/.ssh/hostb/id_rsa
  ssh-keygen –t rsa –C “hostB@email.com
  /c/user/.ssh/hostb/id_rsa  # 当要求输入存储位置时,输入
  然后,在/c/user/.ssh/目录下,建立名为“config”的文件,输入以下内容:
Host 111.111.111.111
HostName 111.111.111.111
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Host 222.222.222.222
HostName 222.222.222.222
PreferredAuthentications publickey
IdentityFile ~/.ssh/hostb/id_rsa
  后,测试一下:
  $ ssh -T 111.111.111.111
  $ ssh -T 222.222.222.222