0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

gitパスワード省略(gitbucket)

Posted at

https://qiita.com/sudahiroshi/items/3d8adca693cd21d0b849

vi ~/.netrc

machine 192.168.xx.xx
login xxx
password yyy

chmod 600 .netrc

##################

https://qiita.com/r-tamura/items/c6e49a3eb7f7f8aafb9d

GPGでパスワードを暗号化する
GPGとは
GPG (GNU Privacy Guard)はOpenPGPの規格に沿って作られた暗号化ソフトで、GNU GPLのもとで公開されているオープンソースソフトウェア。

.netrcの暗号化
GPGで作った鍵を持っていない場合は以下のコマンドで鍵を生成する
$ gpg --gen-key
鍵生成には時間がかかる場合がある。今回行った環境では30分ほどかかった。
参考 : ssh 越しに「gpg --gen-key」を実行したときに乱数生成の段階までくるとハングしてしまったかのようになるのは,「単に時間がかかっているから」らしい.約20分もかかった.

.netrcを暗号化する
暗号化を行うとホームディレクトリに.netrc.gpgファイルが生成される。次に元の.netrcファイルを削除

$ gpg -e -r ~/.netrc
$ ls .netrc*
.netrc .netrc.gpg
$ rm .netrc

git credential helper用のスクリプトに実行権を与え、gitの設定にcredential helperとして追加する
gitで用意されているgpgを使ったnetrc利用のスクリプトがあるので、それに対して実行権を与えることで使えるようになる。

$ sudo chmod +x /usr/share/doc/git-1.8.3.1/contrib/credential/netrc/git-credential-netrc
$ git config --global credential.helper /usr/share/doc/git-1.8.3.1/contrib/credential/netrc/git-credential-netrc
これで、git push,git pullするときに自動的に復号されるので、ユーザ情報の入力なしでpush,pullができるようになる。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?