2
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 3 years have passed since last update.

githubのssh認証と2段階認証

Posted at

githubからコマンドラインでcommit&pushしていたら
Deprecation Mailが通知された。

メールのリンク先
Token authentication requirements for Git operations
要は、githubはtokenベースの認証に移行するようで
BASIC認証ベースのアクセスは非推奨になる模様。

ログイン認証も2要素認証を推奨
コマンドラインでpush&commitしたいのならはSSH認証
とのこと。

SSH認証

SSH認証だとログインユーザー毎でSSHキーを発行しないと
ユーザーが識別できないのでメンドイ。

push&commitする環境

sshの公開鍵を生成

$ mkdir ~/.ssh
$ cd ./ssh
$ ssh-keygen -t rsa -C <emailアドレス>
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
$ ls
id_rsa  id_rsa.pub

id_rsa.pubの中身をクリップボードなどにコピーする

github側の設定

  1. ログインしたら右上のアイコンよりDropdownメニューから「Settings」を選択
  2. 左のサイドメニューより「SSH and GPG Keys」を選択
  3. SSH Keysの左の「New SSH Key」ボタンを選択
  4. Title欄は端末名など、Key欄にid_ras.pubのコピーした内容をペーストし、Add SSH Keyボタンをクリック

gitの設定

プロジェクト内の.git/configを開いて編集

[remote "origin"]
url = <レポジトリまでのパス> #例:git@github.com:aaaa/bbb.git

2段階認証

スマホアプリにて認証を行うとのことだが
QRコードを読み取るのにどのアプリかわからず、
googleレンズなどでで反応しなかったが
「Google認証システム」というアプリでQRコード認識した。

2
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
2
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?