Use Git bash under Windows to connect to git server via SSH

Source: Internet
Author: User
Tags using git

Project development under Windows, using Git to connect to the Git repository via ssh, and SSH to connect with public key.

First you need to download mygit and use git bash after installation. Git bash (with GUI interface, which can be used after installing tortoisegit). I mainly use the command line, its command line system like the Linux Environment Basic Operation command, you can directly see C:, such as cd/d/mygitwork, into my D disk under the engineering directory , put the development of the project.

My action: A key pair was generated in Git bash for Windows with Ssh-keygen ssh-keygen-t RSA, CP. Ssh/id_rsa.pub Authorized_keys renamed. By handing this key to a colleague, who was added to the project Git library as a library creator on GitHub, after I clone the Git library, I can make the commit code, in the following steps:

If you have already generated SSH key with your own mailbox, you can save steps 1 and 2
1. Generate Ssh-key
ssh-keygen-t RSA -C "[email protected]"//front highlighted area for production of private key and public key, and-C for copy to a command under an address

2. Renaming Ssh-key
CP ~/.ssh/id_rsa.pub ~/.ssh/[email Protected]

3. Send mail to git library owner, add it to git library, get permission to use, put ~/.ssh/[email protected] into mail attachment

Connect to git library: SSH mode to use public key to implement the Write function.

(The general company will build its own git server, if it is itself, can use the free git server github.) Specific use, described later)

After the Git repository is built, use git clone to connect, but this kind of library, only read function, no write function. If you want to write, you must use SSH, after connecting, submit their public key, the library's administrator to add the public key to the GIT library, resulting in access rights.

The principle of public key is introduced here Http://hi.baidu.com/beijiqieys/item/4643900f6ae51223a0312dc8

The specific command is to generate a key pair with ssh-keygen-t RSA and create a pair of public private keys on the client (public key file: ~/.ssh/id_rsa.pub; private key file: ~/.ssh/id_rsa)
Then put the public key on the server (~/.ssh/authorized_keys) and keep the private key. When using SSH login, the SSH program sends the private key to match the public key on the server. If the match succeeds, you can log in.

Copy the public key file to the remote server:

$ SCP ~/.ssh/id_dsa.pub [email protected]:p ubkey.txt
$ ssh [email protected]
$ mkdir ~/.ssh
$ chmod. SSH
$ cat Pubkey.txt >> ~/.ssh/authorized_keys
$ RM ~/pubkey.txt
$ chmod ~/.ssh/*
$ exit

The setting of permissions is important because unsafe setting of security settings will make it impossible for you to use RSA functionality.

Cat. Ssh/id_rsa.pub | SSH [email protected]_ip "Cat->>/root/.ssh/authorized_keys"

can also be used

Ssh-keygen #生成证书.

Ssh-copy-id-i id-rsa.pub user @ip #把证书传到远程的那个机器上 and generate Authorized_keys files.

Library creation on GitHub:

Create a GitHub Repository, register a GitHub account (https://github.com/), on GitHub, a project corresponding to a unique git repository, creating a new repository is creating a new project. Access the Dashboard (Dashboard) page, as shown, you can see that there is already one in the repository of interest, but your own repository is zero. There is a button "new Repository" in the list of repositories displayed as zero, click the button to start creating a new repository.

We name the newly created repository "Kxt-example", the corresponding project name is "Kxt-example", the project page is created, the repository is not initialized, and the help to initialize the repository is given, as shown in ( Since my kxt-example has already been initialized, the following image is truncated to another uninitialized project). Be sure to set up git, this website is already very clear, here is no longer introduced.

Note Any GitHub user can use this URL to access this public repository, but only the repository creator Luffyke has read and write permissions, and others have read-only permissions. Before initializing the repository, it is a good idea to verify that you are authenticating with the correct public key.

Use Git bash under Windows to connect to git server via SSH

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.