32

質問:コマンドラインを使用してssh秘密鍵と公開鍵(GitHub / GitLabで使用される)を生成するにはどうすればよいですか?

以下のコマンドはエラーを生成します

sh.exe": syntax error near unexpected token '('

私はWindowsXPを使用しています。

$ ssh-keygen -t rsa -C "xxxx@gmail.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/xxxx/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/xxxx/.ssh/id_rsa.
Your public key has been saved in /c/Users/xxxx/.ssh/id_rsa.pub.
The key fingerprint is:
01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db xxxx@gmail.com
4

5 に答える 5

54

実行するコマンドは

ssh-keygen -t rsa -C "you@example.com"

スクリプトの 2 行目から始まるすべての残りは、ssh-keygen の出力です。

you@example.com を自分のメール アドレスに置き換えます。

追加オプションについては、マニュアルを参照してください。ssh-keygen-b 4096オプションリストに追加して、おそらくより長いキーを使用する必要があります。

于 2010-09-30T08:08:40.870 に答える
0

以下のコマンドを使用して SSH キーを生成します

ssh-keygen -trsa -C user@xyz.com

Enterキーを押すだけで、要求するすべての入力にデフォルト値が適用されます

出力は次のようになります

Generating public/private rsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_rsa): 
/home/user/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/user/.ssh/id_rsa
Your public key has been saved in /home/user/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx user@xyz.com
The key's randomart image is:
+---[RSA xxxx]----+
| ..++xX*Ox        |
| x..xx/+.x. + .   |
|.. +..*+xx x +    |
|... +x+o x.       |
|x.. + +..x        |
|xx.. x            |
|...               |
|x x               |
|x  x.             |
+----[SHA256]------+
  

コマンドを使用してcat、ssh キー ファイルの内容を端末に記録します (ここでは独自のパスを使用します)。

cat /home/user/.ssh/id_rsa.pub

出力は次のようになります

ssh-rsa xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.com

コンテンツをコピーして github アカウントに移動します。[アカウント設定] > [SSH と GPG キー] の設定に移動し、[] をクリックしてNew SSH key、希望する名前を入力し、コピーしたコンテンツを値に貼り付けて保存します。これで、毎回ユーザー名とパスワードを使用せずに変更をコミットする準備が整いました。

于 2021-12-03T17:12:46.923 に答える