未加星标

Working with Github private repository using bash on Windows 10

字体大小 | |
[系统(linux) 所属分类 系统(linux) | 发布者 店小二03 | 时间 2019 | 作者 红领巾 ] 0人收藏点击收藏

There are times we want to collaborate with other collaborators in Github in a private manner. Meaning, we need to work and collaborate on a private Github repository. If you have a Github private reposiotory ready for collaboration, the most proven way to work with that is to leverage one of the following two options.

Leverage SSH keys at the Github account level. So that you can work with Github private repository using SSH keys. The whole idea is that you will be generating an RSA key pair using SSH Key gen utility, add the private key portion of the key pair to the SSH agent and upload the public key portion of the key pair to the Github account settings. The advantage of this approach is that you have one SSH key defined at the Github level to manage or work with all the Github repositories created under that account.
Working with Github private repository using bash on Windows 10
Leverage Deploy Keys at the individual repository level. I have learnt that a Deploy Key can be associated with one Github repository. It cannot be associated with more than one repository.
Working with Github private repository using bash on Windows 10

The advantage of the second approach is that you can have a dedicated key or set of deploy keys for individual repositories.

In this post, i’d be covering the option #1. Basically i will leverage bash on windows 10 to work with private github repository using SSH keys. My windows 10 is set up with ubuntu 18.0.4 for windows sub-system for linux. I’m not covering the steps for setting up bash on windows 10 using windows subsystem for linux.

Navigate to the directory in windows 10, where you want to generate SSH key pair.


Working with Github private repository using bash on Windows 10

Type ‘bash’ on the command prompt. It will launch the bash shell on windows 10. Basically the windows folder that you have pointed will be mounted to the ubuntu 18.0.4 bash shell.

Now you can generate the SSH key pair using ‘ssh-keygen’ utility.

ssh-keygen -t rsa -b 4096 -C “ your_email@example.com “

Enter the name of the file for saving the key pair and provide any arbitrary passphrase when prompted.


Working with Github private repository using bash on Windows 10

Start the ssh on the bash shell. We need to explicty start it, because the run levels of this is different from a standard ubuntu desktop.

eval $(ssh-agent -s)


Working with Github private repository using bash on Windows 10

Add the private key portion of the generated key pair to the SSH agent.

ssh-add keyname

If you getting a permission error for the generated key pair, the key will not get added successfully to the agent.


Working with Github private repository using bash on Windows 10

Even if you try to modify the permission of the key using ‘chmod 400’ or ‘chmod 600’ on the mounted directory, it won’t be successful. Becuase i’ve learnt that changing file permissions using chmod on the mounted directory (from windows 10) does not work.

The best way to fix this is to copy the key to a folder under the ubuntu user root directory, not to any windows mounted directory on bash.

Check if the directory ~/.ssh already exists on the bash shell. If not, explicitly create a directory ~/.ssh and exit the bash shell.

Again, navigate to the directory in windows 10 where the key pairs are generated and launch bash from there.

copy private key to ~/.ssh


Working with Github private repository using bash on Windows 10

Navigate to ~/.ssh and change permissions using any one of the following commands.

chmod 400 sundargitsshkey

chmod 600 sundargitsshkey


Working with Github private repository using bash on Windows 10

Copy the public key of the generated key pair (with ‘.pub’ suffix) to New > SSH Key under Github account settings. Basically copy the content of the public key using any of the text editors and paste there in textbox available in New > SSH Key under Github account settings.

Navigate to the SSH config file located in ‘/etc/ssh/ssh_config’ and add an entry for ‘IdentityFile ~/.ssh/sundargitsshkey’

sudo nano ssh_config


Working with Github private repository using bash on Windows 10

Start the SSH agent explicitly.

eval $(ssh-agent -s)

Verify the connectivity to Github using this command ‘SSH -T git@github.com’

It will ask you to confirm to accept the warning on authenticity of github.com. Accept it and provide passphrase for private key file when prompted. You’ll get the confirmation for successful authentication to make SSH calls into Github account from your bash shell.


Working with Github private repository using bash on Windows 10

Now you do git clone, commit and push to any number of repositories under your Github account using SSH, be it a private repository or public repository.

本文系统(linux)相关术语:linux系统 鸟哥的linux私房菜 linux命令大全 linux操作系统

代码区博客精选文章
分页:12
转载请注明
本文标题:Working with Github private repository using bash on Windows 10
本站链接:https://www.codesec.net/view/628020.html


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 系统(linux) | 评论(0) | 阅读(25)