web-dev-qa-db-ja.com

SSH-Keygen「そのようなファイルまたはディレクトリはありません」

Gitの公開キーを生成しようとしています。 Powershellを使用します。

PS>ssh-keygen -t rsa -b 4096 -C "[email protected]"
Generating public/private rsa key pair.
Enter file in which to save the key (//.ssh/id_rsa):
Could not create directory '//.ssh': Read-only file system
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Saving key "//.ssh/id_rsa" failed: No such file or directory

ファイルの場所を指定して実行した場合

ssh -vT [email protected]

使用する公開キーのカスタムの場所を確認しません

OpenSSH_7.1p1, OpenSSL 1.0.2d 9 Jul 2015
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to github.com [<<ANIPADDRESS>>] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.1
debug1: Remote protocol version 2.0, remote software version libssh-0.7.0
debug1: no match: libssh-0.7.0
debug1: Authenticating to github.com:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client [email protected] <implicit> none
debug1: kex: client->server [email protected] <implicit> none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server Host key: ssh-rsa SHA256:<<SCAREDTOPUBLISH>>
debug1: Host 'github.com' is known and matches the RSA Host key.
debug1: Found key in /.ssh/known_hosts:1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /.ssh/id_rsa
debug1: Trying private key: /.ssh/id_dsa
debug1: Trying private key: /.ssh/id_ecdsa
debug1: Trying private key: /.ssh/id_ed25519
debug1: No more authentication methods to try.
Permission denied (publickey).
15
MarkKGreenway
PS>ssh-keygen -t rsa -b 4096 -C "[email protected]"
Generating public/private rsa key pair.
Enter file in which to save the key (//.ssh/id_rsa):
Could not create directory '//.ssh': Read-only file system
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Saving key "//.ssh/id_rsa" failed: No such file or directory

コマンドはキーを保存できませんでした。書き込みアクセス権がある場所でファイルを指定します。

ssh-keygen -t rsa -b 4096 -C "[email protected]" -f /path/to/key

これにより、秘密鍵が/path/to/keyに、公開鍵が/path/to/key.pubに保存されます。成功すると、エラーメッセージではなく、次のようなメッセージが表示されます。

Your identification has been saved in /path/to/key.
Your public key has been saved in /path/to/key.pub.
The key fingerprint is:
76:f7:82:04:1e:64:eb:9c:df:dc:0a:6b:26:73:1b:2c
The key's randomart image is:
+--[ RSA 2048]----+
|        o        |
|       o .       |
|        +        |
|       + +       |
|        S o .    |
|       . = = o   |
|        E * + o  |
|        o.++ o   |
|         *o..    |
+-----------------+

そして、sshがカスタムの場所でファイルを探すようにするには、-iフラグを使用します。

ssh -i /path/to/key -vT [email protected]

または、認証エージェントを実行している場合は、次を使用してキーをエージェントに追加できます。

ssh-add /path/to/key

キーがエージェントによって保存されると、次のことが簡単にできます。

ssh -T [email protected]

応答は次のようになります。

Hi USER! You've successfully authenticated, but GitHub does not provide Shell access.

そして、次のようにしてリポジトリをクローンすることができます:

git clone [email protected]:USER/REPO
31
janos