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 "[email protected]" -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.

原文地址:https://www.cnblogs.com/daniel123/p/8387694.html

时间: 2024-10-09 23:03:03

SSH key introduction的相关文章

梅林路由器 开启ssh key远程登录

转载自 开启SSH KEY在手机远程登陆路由 http://koolshare.cn/thread-67565-1-1.html (出处: KoolShare) 笔记地址 http://ccdd6ec5.wiz03.com/share/s/3cTmX51TMQ-b2QTact03UPg83Rw4wm1WOAZ92OnR6j06wZqr 首先修改路由的登录名和密码 下载puttygen https://the.earth.li/~sgtatham/putty/latest/x86/puttygen

多个github帐号的SSH key切换

一台电脑上有一个ssh key,在github上提交代码,由于其他原因 你可能会在一台电脑上提交到不同的github上,怎么办呢... 假设你电脑上一个ssh key都没有,如果有默认的一个了,请直接生成第二个 一.生成并添加第一个ssh key $ ssh-keygen -t rsa -C "[email protected]" 在Git Bash中执行命令一路回车,会在~/.ssh/目录下生成id_rsa和id_rsa.pub两个文件 用文本编辑器打开id_rsa.pub里的内容,

github入门:设置添加ssh key<转>

转自:http://blog.csdn.net/binyao02123202/article/details/20130891 很多朋友在用github管理项目的时候,都是直接使用https url克隆到本地,当然也有有些人使用 SSH url 克隆到本地.然而,为什么绝大多数人会使用https url克隆呢? 这是因为,使用https url克隆对初学者来说会比较方便,复制https url 然后到 git Bash 里面直接用clone命令克隆到本地就好了.而使用 SSH url 克隆却需要

window下配置SSH连接GitHub、GitHub配置ssh key(转载自 http://jingyan.baidu.com/article/a65957f4e91ccf24e77f9b11.html)

此经验分两部分: 第一部分介绍:在windows下通过msysGit(Git for windows.Git Bash)配置SSH Keys连接GitHub. 第二部分介绍:在GitHub上创建仓库,在本地创建项目,然后将本地项目通过SSH提交到GitHub仓库中. 工具/原料 GitHub msysGit(git for windows.Git Bash) msysGit配置SSH访问GitHub 1 检查本机是否有ssh key设置 $ cd ~/.ssh 或cd .ssh 如果没有则提示:

git ssh key 配置 Ubuntu os

1.生成ssh key: ssh-keygen -t rsa -C “[email protected]” 此时,在~/.ssh/文件夹下会有两个文件, id_rsa 和 id_rsa.pub.分别保存ssh 的密钥和公钥. 2.把id_rsa.pub里面的内容复制到gitlab服务器内个人账号下的ssh_key部分. 3.在本地添加密钥: ssh-add ~/.ssh/id_rsa 这步在linux下似乎是必要的,不添加这步会导致识别不了账号密码.在windows下则不需要这一步. 4.从gi

window下配置SSH连接GitHub、GitHub配置ssh key(转)

转自:http://jingyan.baidu.com/article/a65957f4e91ccf24e77f9b11.html 此经验分两部分: 第一部分介绍:在windows下通过msysGit(Git for windows.Git Bash)配置SSH Keys连接GitHub. 第二部分介绍:在GitHub上创建仓库,在本地创建项目,然后将本地项目通过SSH提交到GitHub仓库中. 工具/原料 GitHub msysGit(git for windows.Git Bash) msy

解决git本地多ssh key的问题

最近手上一个项目需要使用到一台服务器作为专用的部署服务器,在实施过程中遇到了一些问题,具体如下: 1. 服务器的ssh默认端口和项目git仓库的ssh端口不一致 2. 部署需要使用项目提供的ssh key,不能使用服务器本身的默认ssh key 这些问题都被顺利解决了,这里特记录一下,防止遗忘. 针对上述问题,下面主要从这三个点来记录解决方案. 如何生成ssh key 如何使用特定ssh端口从git仓库拉取项目 如何使用特定密钥文件从git仓库拉取项目 一.生成 ssh key 系统默认的ssh

第三十天-ssh key企业批量分发自动化管理案例

本文实现一个应用ssh key 批量分发案例 目录 一.ssh key 原理及案例原理简图 1.ssh key 简介 2.rsa和dsa区别 3.ssh-copy-id的特殊应用 4.ssh-copy-id的原理 5.案例简图 二.操作步骤 三.具体实现步骤 服务端A: 客户端B: 客户端C: 四.ssh 批量分发与管理方案小结 五.企业级生产场景批量管理,自动化管理方案 一.ssh key 原理及案例原理简图 1.ssh key 简介 特别提示:在整个方案实现中,公钥(public key)和

【转】同一台电脑关于多个SSH KEY管理

原文链接 http://yijiebuyi.com/blog/f18d38eb7cfee860c117d629fdb16faf.html 使用环境:关于同一台电脑LInux系统下使用多个SSH key 切换使用(或者多用户使用ssh提交代码) 要求,可以创建不同的 PUBLIC KEY ,根据下面步骤设置. (1)比如有aaa,bbb,ccc 三个帐号需要生成不同的 PUBLIC KEY $ ssh-keygen -t rsa Generating public/private rsa key