SSH key introduction
Preface
At the first time, we take the connection with GitLab remote server. You need to type username and password as your individual credentials to login the server, since the connection between the client(your computer) and remote server(Git sever in a Linux machine) is built up SSH protocol. But every programmer want things to be simple next time, in order to reach the target, the SSH key is introduced to help us for login without manual authentication.
Begin you start…
if you have already know a little about Git, or you are being trained to know how to use Git for PLM. Perhaps the document can help you, Trust me, if you don’t know any context. The documentary will be boring and useless. actually, there is another choice of connection to GitLab remote server, you will also know it at the subsequent section.
Steps for deploying SSH keys
Note: the steps have already describe in your GitLab server, if you want to know more, click the reference http://10.8.0.68/help/ssh/README . if you couldn’t access to the link ,the document will tell you directly at subsequent section, the following steps can help you to know how to finish the job completely, even better.
1. Locating an existing SSH key
Because there is possible that your machine had already been used by other developers and generated the SSH key when they configured their Git environment. So that, Before generating a new SSH key check if your system already has one at the default location by opening a Shell(Git Bash), or Command Prompt on Windows(CMD), and running the following command:
a) Windows Command Prompt:
type %userprofile%\.ssh\id_rsa.pub
b) Git Bash on Windows :
cat ~/.ssh/id_rsa.pub
If you see a string starting with ssh-rsa you already have an SSH key (this case will appear like above), but the key probably is not mapped to your identity. You have to know real place where your SSH key actually is located in. and to remove this files beneath the directory, and generate new SSH key in accordance to your credential. the path is like the following pattern.
C:\Users\DanielDai\.ssh
the three important file are described below, if you are not interested in the concrete explanation, please ignore it.
id_rsa:
The file contains private key for encryption in client terminal, when you login GitLab remote server through SSH protocol, private key is used to encrypt your username and Password(if there is).
Id_rsa.pub:
The file contains public key for decryption in server terminal, when server receive the your credential which have been encrypted via private key. And the server decrypt the information and check if this person’s login information is correct.
Known_hosts:
GitLab remote server address and public key of GitLab server are stored in this file. the file content is used to decrypt information from remote server.
2. Generating an SSH key
To Generate a new SSH key, you can do it through the following instructive commands.
a) Git Bash on Windows:
ssh-keygen -t rsa -C "your.email@example.com" -b 4096
you will be noticed as the following prompt.
I suggest you press “enter” key without other thought if you configure your Git environment initially. Because using the suggested path will normally allow your SSH client to automatically use the SSH key without any additionally configuration. In other words, you don’t need to configure .git/config in local source repository. If you don’t know what .git/config is, referring toUse on Git. Of course, you have other choices for your customized requirement, but here is not going to introduce that alternative in details.
b) Input a password
Once you input a file path, you will be prompted to input a password for security of your SSH key, although safety will be promised , I don’t recommend you to input password. It will be more simple and faster.
c) Duplicate the public SSH key as somewhere need it afterwards
To copy the content, you can use the following commands to do that. Of course, opening up id_rsa.pub and then getting a duplication are more visual.
Git Bash on Windows:
cat ~/.ssh/id_rsa.pub | clip
3. setting up an SSH key
return back GitLab management Page,navigate to the “SSH Keys” tab in your ‘Settings’.Paste your key in the ‘Key’ section and give it a relevant and identifiable ‘Title’.
Understanding of SSH and SSH key
Description: the section is about to conclude the fundamentals about SSH key. what is SSH protocol, what is SSH key, why the connection between Git client and GitLab remote server need the mechanical security system, and how does the security system work in our Git . If you are familiar with the knowledge, you don’t have to look through the chapter.
SSH protocol
Background
Over many years, intercommunication between computer terminals was based on plaintext.it caused too much securable risks that message is easy to be intercepted and captured. SSH protocol targets to resolve the risky issue. The transmission of information between multiple terminals will be encrypted and decrypted via SSH protocol. The material of encryption and decryption is SSH key, more information about SSH key is introduced in subsequent section.
Usage
SSH is typically used to log into a remote machine and process some tasks remotely. There are some helpful tools for that, such as putty, mremoteNG etc. of course, the Git bash is inclusive. we use SSH client to connect remote server to avoid using the Linux server on-site, and Git Lab remote server is belonging to Linux sever too.
SSH Key
Background
Actually, we should name it SSH key pairs or (SSH public key and SSH private key).Because SSH protocol is built up on Public and private key encryption mechanism.
Public and private key encryption mechanism
If there is an encrypted connection between two standalone entities, then, message that is encrypted by an entity’s private key require to be decrypted via this entity’s public key. so before establishment of network connection, another entity need know this entity’s public key.
So entity should generate a public key and a private key meanwhile using it’s key generation program.
the following pic could demonstrate the system well.
How does the security system work in our Git
As principle which is described above. So firstly, the GitLab remote server needs to save the client’s public key for decrypting user’s credentials from client. That is why we need to configure SSH key before.
For all files beneath the directory(C:\Users\DanielDai\.ssh) indicated at previous chapter. If you didn’t get completely understanding of that instruction, I advise you should review it again.
No matter what messages that are from Git client or Git Server will be transfer to each other based on SSH channel, so that, not only we need to deploy the SSH public key of Git Client to Git Server, but we also need to save the SSH public key of Git Server when Git client try to connect to an new server address at the first time.
Here is a good example, I think it can demonstrate the what the functional of the file (known_hosts) is.
The email from GiorGio tell us the change of GitLab remote Server Address, we need to replace the old address with new one.
After configure it already, the Git client will meet the following noticeable prompt when client try to connect to new address at the first time. If your response is ‘yes’, known_hosts file will save a new server address and the ssh public key from the sever.
Alternatives Of Connection To GitLab Remote Server
If you only know how to follow all steps to deploy the SSH key, of course, that is enough for development of Luxottica PLM. But , actually, there is another alternatives to connect to GitLab Remote Sever generally. You can do the same things through “HTTPS/HTTP” channel.
The following screenshots shows how you can choose it.
If you choose the alternative, you don’t have to generate SSH key pairs and to deploy SSH public key to GitLab Server.
SSH key introduction的更多相关文章
- git生成公钥public key并添加SSH key。git乌龟gerrit下推送git【server sent :publickey】
一.key 码云链接:http://git.mydoc.io/?t=180845#text_180845 博客链接: 方式一:https://blog.csdn.net/xb12369/article ...
- 创建SSH Key连接github或gitlab
mac下用SoureceTree下载github或gitlab上的项目时,需要进行ssh key验证.每次重装系统啥的都要重新弄,我在csdn上看到一篇不错的文章.转载一下,以后自己找起来也方便. 地 ...
- ssh key生成
Mac电脑用终端生成SSH key 访问自己的Github 字数684 阅读427 评论4 喜欢15 前言:最近有不少刚刚使用github管理代码的开发者或者新手码农在网上 问我如何关联自己的gith ...
- windows系统如何添加ssh key到github
我自己的电脑安装了git后,从来没有用过,今天偶然用了一次,发现不能pull到东西,报错说我没有权限,于是我网上搜索了一下,应该是我没有配置ssh key的原因,相信很多人都有和我一样的经历吧,这里呢 ...
- github with msysgit:配置SSH Key
Step 1: Check for SSH keys First, we need to check for existing ssh keys on your computer. Open up G ...
- 添加ssh key
我现在根据<github入门和实践>来去摸索github 其实,我发现自己在看github时,感觉不适应,是因为自己太久没有碰到英文了.可以联想到以前当看到一个网页,根据汉字的标题或描述, ...
- github 添加 SSH key
在 github 上添加 SSH key 的步骤: 1.首先需要检查你电脑是否已经有 SSH key 运行 git Bash 客户端,输入如下代码: $ cd ~/.ssh $ ls 这两个命令就是检 ...
- 使用ssh key的方式建立和git服务器的通信
1.以前大家好像都在用https的方式同git来同步代码,但是到了新公司后,主管说要配ssh key,所以大概了解一下 An SSH key allows you to establish a sec ...
- Git bash 配置ssh key
问题描述 昨天为了配置Qt create中的Git,把我一直在使用的Github删除了,今本以为,这样git的一些配置还在,可是,今天上传一些提交的时候,提示我,git没有密钥.梳理一下,这个简单的配 ...
随机推荐
- JS 时间转换为时间戳
Date.prototype.format = function(fmt) { var o = { "M+" : this.getMonth()+1, //月份 "d+& ...
- duilib基本框架
最近我一个同学在项目中使用到了duilib框架,但是之前并没有接触过,他与我讨论这方面的内容,看着官方给出的精美的例子,我对这个库有了很大的兴趣,我自己也是初学这个东东,我在网上花了不少时间来找相关的 ...
- python之 正则表达式
简介 Python 自1.5版本起增加了re 模块,它提供 Perl 风格的正则表达式模式.Python 1.5之前版本则是通过 regex 模块提供 Emacs 风格的模式.Emacs 风格模式可读 ...
- jdk1.8新特性 : 接口中可以有普通方法(非静态方法)和静态方法 , 颠覆了之前我的理解 : 接口中只能有共有常量和抽象方法的概念,后面必须要加一句jdk1.7和1..7之前
看到jdk某些接口中存在default方法,于是... http://shaomeng95.iteye.com/blog/998820 为什么接口只能是公有常量? public interfac ...
- 记一次lvs-tunnel模式的故障分析(7)
一.测试环境 类型 IP 负载均衡器 eth0:10.20.73.20 VIP eth0:0 10.20.73.29 后端真实机 10.0.0.7(web01).10.0.0.9(web02) ...
- weui中的日期选择控件关于时间段的设置!
近日用到了日期控件,但是需要把时和分去掉,功能上是做一个预约的功能,所以只需要在年月日后面提供时间段的选择. BUG在于如果第一次点开弹框而没做任何操作,然后点了其他任意区域则弹框关闭,甚至你的8:0 ...
- CSS3中nth-of-type和nth-last-of-type
1.使用nth-child和nth-last-child时会产生的问题 在使用nth-child和nth-last-child时,其计算子元素是奇数个元素还是第偶数个元素时,是连同父元素中的所有子元素 ...
- BZOJ 3668: [Noi2014]起床困难综合症【贪心】
3668: [Noi2014]起床困难综合症 Time Limit: 10 Sec Memory Limit: 512 MBSubmit: 2326 Solved: 1305[Submit][St ...
- bzoj:1598: [Usaco2008 Mar]牛跑步
Description BESSIE准备用从牛棚跑到池塘的方法来锻炼. 但是因为她懒,她只准备沿着下坡的路跑到池塘, 然后走回牛棚. BESSIE也不想跑得太远,所以她想走最短的路经. 农场上一共有M ...
- 51Nod 1046 A^B Mod C(日常复习快速幂)
1046 A^B Mod C 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 给出3个正整数A B C,求A^B Mod C. 例如,3 5 8,3^5 Mod 8 = ...