2012-12-08 52 views

回答

8

可以使用-i選項。

來源:man ssh

-i identity_file 
    Selects a file from which the identity (private key) for public key authentication is read. The default is ~/.ssh/identity for protocol 
    version 1, and ~/.ssh/id_dsa, ~/.ssh/id_ecdsa and ~/.ssh/id_rsa for protocol version 2. Identity files may also be specified on a per- 
    host basis in the configuration file. It is possible to have multiple -i options (and multiple identities specified in configuration 
    files). ssh will also try to load certificate information from the filename obtained by appending -cert.pub to identity filenames. 
2

您還可以添加特定的配置,您訪問的每個主機,這是幾乎一樣堅持以SSH提供的標誌的使用。

有一個可用的標誌的整個世界,併爲每個不同的服務專業化提供了一些映射。在你的情況下,使用特定的id_rsa文件,你可以寫下你的~/.ssh/config文件:

... 

Host host_alias 
    HostName host_name 
    IdentityFile ~/.ssh/id_rsa_you_want 

... 

然後,您可以簡單地使用:

ssh host_alias 

而且id_rsa_you_want將使用 - 以及您可以將任何進一步的配置應用於連接。有關可用指令的完整列表,請參閱man ssh_config