在您的 ~/.ssh/config 文件中(如果它不存在则创建它),您可以指定使用 IdentityFile 指令的键:
IdentityFile ~/path/to/your/key
Run Code Online (Sandbox Code Playgroud)
如果您只想将该密钥用于特定主机,则可以在“主机”部分中使用此指令。例如:
Host *.example.com
IdentityFile ~/.ssh/identity-example.com
Run Code Online (Sandbox Code Playgroud)
如果您运行“ssh -v hostname”,调试信息应确认它正在使用您指定的密钥。