12

sshデフォルトのディレクトリを無視して実行し.ssh、他の 1 つまたはより適切に指定された秘密鍵を指定することは可能ですか?

例えば:

ssh --private-key other_id_rsa login@host
4

3 に答える 3

15

オプションをご利用いただけ-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.
于 2012-12-08T15:15:32.623 に答える
4

アクセスする各ホストに特定の構成を追加することもできます。これは、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使用可能なディレクティブの完全なリストについては、を参照してください。

于 2013-01-01T22:57:00.730 に答える