Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
81bfa925
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
81bfa925
编写于
12月 09, 2016
作者:
A
Achilleas Pipinellis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactor SSH keys docs
[ci skip]
上级
1038d376
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
70 addition
and
65 deletion
+70
-65
doc/ssh/README.md
doc/ssh/README.md
+70
-65
未找到文件。
doc/ssh/README.md
浏览文件 @
81bfa925
...
...
@@ -5,7 +5,7 @@ but you can also share or "push" your changes to other servers.
Before you can push your changes to a GitLab server
you need a secure communication channel for sharing information.
GitLab uses Public-key or asymmetric cryptography
which
"encrypts"
a communication channel by locking it with your "private key"
which
encrypts
a communication channel by locking it with your "private key"
and allows trusted parties to unlock it with your "public key".
If someone does not have your public key they cannot access the unencrypted message.
...
...
@@ -16,10 +16,13 @@ at the default location by opening a shell, or Command Prompt on Windows,
and running the following command:
**Windows Command Prompt:**
```
bash
type
%userprofile%
\.
ssh
\i
d_rsa.pub
```
**GNU/Linux/Mac/PowerShell:**
**GNU/Linux / macOS / PowerShell:**
```
bash
cat
~/.ssh/id_rsa.pub
```
...
...
@@ -27,78 +30,82 @@ cat ~/.ssh/id_rsa.pub
If you see a string starting with
`ssh-rsa`
you already have an SSH key pair
and you can skip the next step
**Generating a new SSH key pair**
and continue onto
**Copying your public SSH key to the clipboard**
.
If you don't see the string or would like to generate a SSH key pair with a
custom name
continue onto the next step.
If you don't see the string or would like to generate a SSH key pair with a
c
ustom name c
ontinue onto the next step.
## Generating a new SSH key pair
To generate a new SSH key, use the following command:
1.
To generate a new SSH key, use the following command:
**GNU/Linux/Mac/PowerShell:**
```
bash
ssh-keygen
-t
rsa
-C
"
$your_email
"
```
**GNU/Linux / macOS:**
**Windows:**
On Windows you will need to download
[
PuttyGen
](
http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
)
and follow this documentation
[
article
](
https://the.earth.li/~sgtatham/putty/0.67/htmldoc/Chapter8.html#pubkey-puttygen
)
to generate a SSH key pair.
```bash
ssh-keygen -t rsa -C "GitLab" -b 4096
```
### Provide a file path
**Windows:**
You will be prompted to input a file path to save your key pair to.
On Windows you will need to download
[PuttyGen](http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html)
and follow this [documentation article][winputty] to generate a SSH key pair.
If you don't already have an SSH key pair use the suggested path by pressing enter.
Using the suggested path will allow your SSH client
to automatically use the key pair with no additional configuration.
1.
Next, you will be prompted to input a file path to save your key pair to.
If you already have a key pair with the suggested file path you will need to input a new file path
and declare what host this key pair will be used for in your
`.ssh/config`
file,
see
**Working with non-default SSH key pair paths**
for more inform
ation.
If you don't already have an SSH key pair use the suggested path by pressing
enter. Using the suggested path will allow your SSH client
to automatically use the key pair with no additional configur
ation.
### Provide a password
If you already have a key pair with the suggested file path, you will need
to input a new file path and declare what host this key pair will be used
for in your `.ssh/config` file, see **Working with non-default SSH key pair paths**
for more information.
Once you have input a file path you will be prompted to input a password to secure your SSH key pair.
Note: It is a best practice to use a password for an SSH key pair,
but it is not required and you can skip creating a password by pressing enter.
1.
Once you have input a file path you will be prompted to input a password to
secure your SSH key pair. It is a best practice to use a password for an SSH
key pair, but it is not required and you can skip creating a password by
pressing enter.
If you want to change the password of your key, you can use the following command:
`ssh-keygen -p <keyname>`
>**Note:**
If you want to change the password of your key, you can use `ssh-keygen -p <keyname>`.
## Copying your public SSH key to the clipboard
1.
The next step is to copy the public key as we will need it afterwards.
To copy your public key to the clipboard, use the appropriate code for you operating system below:
To copy your public key to the clipboard, use the appropriate code for your
operating system below:
**Windows Command Line:**
```
bash
type
%userprofile%
\.
ssh
\i
d_rsa.pub | clip
```
**macOS:**
**Windows PowerShell:**
```
bash
cat
~/.ssh/id_rsa.pub | clip
```
```bash
pbcopy < ~/.ssh/id_rsa.pub
```
**Mac:**
```
bash
pbcopy < ~/.ssh/id_rsa.pub
```
**GNU/Linux (requires the xclip package):**
**GNU/Linux (requires xclip):**
```
bash
xclip
-sel
clip < ~/.ssh/id_rsa.pub
```
```bash
xclip -sel clip < ~/.ssh/id_rsa.pub
```
**Windows Command Line:**
```bash
type %userprofile%\.ssh\id_rsa.pub | clip
```
## Adding your public SSH key to GitLab
**Windows PowerShell:**
Navigate to the 'SSH Keys' tab in you 'Profile Settings'.
Paste your key in the 'Key' section and give it a relevant 'Title'.
Use an identifiable title like 'Work Laptop - Windows 7' or 'Home MacBook Pro 15'.
```bash
cat ~/.ssh/id_rsa.pub | clip
```
If you manually copied your public SSH key make sure you copied the entire key
starting with
`ssh-rsa`
and ending with your email.
1.
The final step is to add your public SSH key to GitLab.
Navigate to the 'SSH Keys' tab in you 'Profile Settings'.
Paste your key in the 'Key' section and give it a relevant 'Title'.
Use an identifiable title like 'Work Laptop - Windows 7' or
'Home MacBook Pro 15'.
If you manually copied your public SSH key make sure you copied the entire
key starting with `ssh-rsa` and ending with your email.
## Working with non-default SSH key pair paths
...
...
@@ -113,21 +120,17 @@ Below are two example host configurations using their own key:
# GitLab.com server
Host gitlab.com
RSAAuthentication yes
IdentityFile ~/folder1/private-key-filename
User mygitlabusername
IdentityFile ~/.ssh/config/private-key-filename-01
# Private GitLab server
Host gitlab.company.com
RSAAuthentication yes
IdentityFile ~/
folder2
/private-key-filename
IdentityFile ~/
.ssh/config
/private-key-filename
```
Note in the gitlab.com example above a username was specified
to override the default chosen by OpenSSH (your local username).
This is only required if your local and remote usernames differ.
Due to the wide variety of SSH clients and their very large number of configuration options,
further explanation of these topics is beyond the scope of this document.
Due to the wide variety of SSH clients and their very large number of
configuration options, further explanation of these topics is beyond the scope
of this document.
Public SSH keys need to be unique, as they will bind to your account.
Your SSH key is the only identifier you'll have when pushing code via SSH.
...
...
@@ -152,13 +155,15 @@ If you want to add the same key to another project, please enable it in the
list that says 'Deploy keys from projects available to you'. All the deploy
keys of all the projects you have access to are available. This project
access can happen through being a direct member of the project, or through
a group. See
`def accessible_deploy_keys`
in
`app/models/user.rb`
for more
information.
a group.
Deploy keys can be shared between projects, you just need to add them to each project.
Deploy keys can be shared between projects, you just need to add them to each
project.
## Applications
### Eclipse
How to add your ssh key to Eclipse: https://wiki.eclipse.org/EGit/User_Guide#Eclipse_SSH_Configuration
[
winputty
]:
https://the.earth.li/~sgtatham/putty/0.67/htmldoc/Chapter8.html#pubkey-puttygen
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录