linux ssh 连接某个主机时,指定私钥的路径

1.修改当前登录用户的 ssh 环境变量文件(没有则新增)

vim ~/.ssh/config

2.根据需求,定义需要连接的主机的私钥路径(可以定义多个不同的主机)

Host github.com
  User git
  Hostname github.com
  IdentityFile ~/data/.ssh/git_id_rsa

Host 172.16.3.25
  User lowman
  Hostname 172.16.3.25
  IdentityFile ~/data/.ssh/my_id_rsa

根据实际情况修改成自己的信息即可

原文地址:https://www.cnblogs.com/lowmanisbusy/p/12683943.html