Git配置ssh,並實現免密pull, push

  • 生成public/private key pair

    ssh-keygen -t rsa -C "github賬號的郵箱"
    
  • 進入存放密鑰的目錄,複製public key的內容

  • 將public key添加到github上

  • 免密pull, push

    # 在緩存中寫入賬號密碼,接下來15minutes內可免密pull, push
    git config --global credential.helper cache
    
    # 在磁盤中寫入賬號密碼,下次pull, push時直接從磁盤中讀取
    git config --global credential.helper store
    # 這種方式的缺點是你的密碼是用明文的方式存放在你的 home 目錄下
    
  • 第一次pull/push需要輸入賬號密碼,接下來就可以快速的push啦!

  • 刪除保存在 cache/store 中的Git賬號密碼

    # 在root權限下
    git config --system --unset credential.helper
    

想了解配置ssh的詳情可移步:雲服務器配置ssh登陸(putty + puttygen)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章