新机git及github sshkey简单配置

 

新机git简单配置,毕竟不常用,不用每次都查
1、安装git
windows:https://git-scm.com/download/win
ubuntu: apt install git

2、全局配置

git config --global user.name "you_name"
git config --global user.email "your_email@gmail.com"


3、生成ssh-key
ssh-keygen -t rsa -b 4096 -C "your_email@gmail.com"

4、添加ssh到github 以后不用每次都输入邮箱及密码
cat ~/.ssh/id_rsa.pub
把输出的内容拷贝到github上
github 在https://github.com/settings/keys
点击左上角 New SSH key 把刚才的内容复制到下面的框里,点击Add SSH key

5、可以clone你自己的代码 然后修改提交了

如果新创建一个仓库也会有对应的提示:

echo "# test" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/crazypenguincode/test.git
git push -u origin master

 

git remote add origin https://github.com/xxx/test.git
git push -u origin master

 

参考:

https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/

  1. Open Terminal.

  2. Paste the text below, substituting in your GitHub email address.

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

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

    Generating public/private rsa key pair.
    
  3. 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 (/home/you/.ssh/id_rsa): [Press enter]
    
  4. At the prompt, type a secure passphrase. For more information, see "Working with SSH key passphrases".
    Enter passphrase (empty for no passphrase): [Type a passphrase]
    Enter same passphrase again: [Type passphrase again]
    

https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/

Note: DSA keys were deprecated in OpenSSH 7.0. If your operating system uses OpenSSH, you'll need to use an alternate type of key when setting up SSH, such as an RSA key. For instance, if your operating system is MacOS Sierra, you can set up SSH using an RSA key.

  1. Copy the SSH key to your clipboard.

    If your SSH key file has a different name than the example code, modify the filename to match your current setup. When copying your key, don't add any newlines or whitespace.

    $ sudo apt-get install xclip
    # Downloads and installs xclip. If you don't have `apt-get`, you might need to use another installer (like `yum`)
    
    $ xclip -sel clip < ~/.ssh/id_rsa.pub
    # Copies the contents of the id_rsa.pub file to your clipboard
    

    Tip: If xclip isn't working, you can locate the hidden .ssh folder, open the file in your favorite text editor, and copy it to your clipboard.

  2. Settings icon in the user barIn the upper-right corner of any page, click your profile photo, then click Settings.

  3. Authentication keysIn the user settings sidebar, click SSH and GPG keys.

  4. SSH Key buttonClick New SSH key or Add SSH key.

  5. In the "Title" field, add a descriptive label for the new key. For example, if you're using a personal Mac, you might call this key "Personal MacBook Air".
  6. The key fieldPaste your key into the "Key" field.
  7. The Add key buttonClick Add SSH key.
  8. Sudo mode dialogIf prompted, confirm your GitHub password.

转载于:https://www.cnblogs.com/zhishuai/p/7850595.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值