Notes on linux

This is a simple note, I don't have clear index to arrage the content in this note. I just take the notes which I may be easy forget.

Author: Yue-Wen FANG

Contact: fyuewen@gmail.com

Revision history: created in 16th, December 2017, at Kyoto

1. 配置ssh连接

Professionally speaking, it's better to use a English title: Configure Custom Connection Options for your SSH Client

Generating a new SSH key

On github help webpage (see Ref1), there is a simple introduction on generating the ssh key pairs.

Open your terminal (no matter it is on Cygwin or Linux or Wingw or any other virtual linux systems):

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

This creates a new ssh key, using the provided email as a label.

Beforing reading my note, I think you could have see kygen command like

ssh-keygen -t rsa -b 2048 -C "your_email@example.com"

The only difference is the bit we use. It determines the length of the generated kyes. You can use either on your favor.

When you're prompted to "Enter a file in which to save the key," press Enter. This accepts the default file location.

Enter a file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]

you can also use a new address, like /Users/you/.ssh/id_rsa.cluster

At the prompt, type a secure passphrase. (usually I just Press enter)

Adding your SSH key to the ssh-agent

Start the ssh-agent in the background.

eval "$(ssh-agent -s)"

THIS COMMAND WILL SHOW YOU AS "Agent pid 59566"

Add your SSH private key to the ssh-agent. If you created your key with a different name, or if you are adding an existing key that has a different name, replace id_rsa in the command with the name of your private key file.

ssh-add ~/.ssh/id_rsa

2. Add your public key to github

You can copy the content in ~/.ssh/id_rsa to your github (setting-> SSH and GPG keys->New SSH key or Add SSH key). Then you can use git push without inputing the password.

3. Specify a key pair?

Sometimes you may have several different key pairs (that means you have several id_rsa files like id_rsa.home id_rsa.work), and you want to use them in some specific conditions, what should we do?

We can use the config file in ~/.ssh, if you don't find it, just create this config file.

You can folow this guide to set up your config file (see Ref2 or Ref3)

If you know Chinese, you can also read there blogs in which the authors showed their thoughts on config file:

http://blog.csdn.net/u013647382/article/details/47832559

http://dhq.me/use-ssh-config-manage-ssh-session

https://www.hi-linux.com/posts/14346.html


In [ ]: