当前位置: 首页 > Linux

SSH多密钥管理

时间:2023-04-06 22:33:57 Linux

工作中经常需要使用不同的私钥登录不同的服务器,所以需要对不同的私钥进行管理。首先,添加新的私钥时,需要生成不同的文件名ssh-keygen-trsa-f~/.ssh/id_rsa.work-C"keyforwork"ssh-keygen-trsa-f~/.ssh/id_rsa.github-C"keyforgithub"添加新的ssh配置文件并修改权限touch~/.ssh/configchmod600~/.ssh/config编辑配置文件vi~/.ssh/configHost*.workdomain.comHostName*.workdomain.comIdentityFile~/.ssh/id_rsa.workHostgithub.comHostNamegithub.comUsergitIdentityFile~/.ssh/id_rsa.githubHost是别名HostName是服务器的域名或者IPUser表示是哪个用户name用于登录IdentityFile表示使用哪个私钥进行认证登录sshroot@www.workdomain.com或sshgithub.com