Add SSH key for project
作者:互联网
Before you create a key pair, see if a key pair already exists.
1. Go to your home directory.
2. Go to the .ssh/ subdirectory. If the .ssh/ subdirectory doesn't exist, you are either not in the home directory, or you haven't used ssh before. In the latter case, you need to generate an SSH key pair.
For macOS, use command+shift+. to show the hidden file folders.
3. See if a file with one of the following formats exists:
Generate an SSH key pair
If you do not have an existing SSH key pair, generate a new one:
-
Open a terminal.
-
Run
ssh-keygen -t
followed by the key type and an optional comment. This comment is included in the.pub
file that's created. You may want to use an email address for the comment.For example, for ED25519:
ssh-keygen -t ed25519 -C "<comment>"
For 2048-bit RSA:
ssh-keygen -t rsa -b 2048 -C "<comment>"
-
Press Enter. Output similar to the following is displayed:
Generating public/private ed25519 key pair. Enter file in which to save the key (/home/user/.ssh/id_ed25519):
-
Accept the suggested filename and directory, unless you are generating a deploy key or want to save in a specific directory where you store other keys.
You can also dedicate the SSH key pair to a specific host.
-
Specify a passphrase:
Enter passphrase (empty for no passphrase): Enter same passphrase again:
A confirmation is displayed, including information about where your files are stored.
标签:file,passphrase,project,Add,SSH,key,pair,ssh 来源: https://www.cnblogs.com/muyang99/p/16452511.html