[Flutter][Tips][10] Git にpushするときの remote: Invalid username or password. エラーの対応

結論から言うと、RSAキーを登録したのですが、それでもダメだったので金輪際ユーザー名とパスワードを聞かれなくすることで解決しました。
でも、多分あまり推奨される方法じゃないので、まずはRSAキーの登録を試してみましょう。
remote: Invalid username or password. への対応① RSAキー接続を確かめる
RSAキーでgithubに接続できるか試してみましょう。
ssh -T [email protected]
こんなエラーメッセージが出ました。
RSA key fingerprint is SHA256:ほにゃらら Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added 'github.com,ほにゃららら' (RSA) to the list of known hosts. [email protected]: Permission denied (publickey).
あかんやん。
もうホントこう言うのイラつく。
なんだってオイラはいつもいつもどーでもいいとこでつまずくかなぁ。
SHA256の鍵で繋げらんねーよと怒られているので、新しく登録します。
remote: Invalid username or password. への対応② RSAキーを新しく作って接続する
% cd ~/.ssh/ % ssh-keygen -t rsa -C "メールアドレス" Generating public/private rsa key pair. Enter file in which to save the key (/Users/ホゲホゲ/.ssh/id_rsa): github_id_rsa Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in github_id_rsa. Your public key has been saved in github_id_rsa.pub. The key fingerprint is: ほにゃららぽげぽげ The key's randomart image is: ...(略)
ここまででRSAキーが作成されたので、以下のコマンドでクリップボードにコピーします。
% pbcopy < ~/.ssh/github_id_rsa.pu
で、GitHubにログインして、[Setting]の[SSH and GPG keys]のページを開き、SSH keysの[New SSH key]ボタンを押します。
からの〜
からの〜
ここに貼り付け!
終わったら、ターミナルに戻って以下を実行しましょう。
% vi ~/.ssh/config Host github.com HostName github.com IdentityFile ~/.ssh/github_id_rsa User git % ssh -T [email protected] Hi なまえ! You've successfully authenticated, but GitHub does not provide shell access.
成功です。無事認証されました。
もう一回!
あかんやん!
remote: Invalid username or password. への対応③ 金輪際ユーザ名とパスワードを聞かれなくする方法
もう怒ったぞ! やめだやめだー!
Android Studioのターミナルでこうして….
% vi .git/config
で、これを
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[remote "origin"]
url = https://github.com/ほにゃららぽんぽん.git
fetch = +refs/heads/*:refs/remotes/origin/*
...
これを…..
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[remote "origin"]
url = [email protected]:ほにゃららぽんぽん.git
fetch = +refs/heads/*:refs/remotes/origin/*
...
こうしてやるー!(赤字部分を書き換える)
ちなみに[email protected]〜〜〜はGitHubのリポジトリでHTTPSではなくSSHを選択するとコピーできます。
これで、金輪際ユーザー名とパスワードを聞かれなくなります。
ふー。
もっかい
% git push -u origin master
ってしたらできました!
Warning: Permanently added the RSA host key for IP address 'ぽんぽぽぽん' to the list of known hosts. Enumerating objects: 98, done. Counting objects: 100% (98/98), done. Delta compression using up to 8 threads Compressing objects: 100% (80/80), done. ...
何か警告が出ましたね。
警告:IPアドレス「ぽんぽぽぽん」のRSAホストキーが既知のホストのリストに永久に追加されました。
なるほど、IPアドレスがさっきRSAキーで登録したやつと違う気がします。だからログインできなかったんですね。まぁちゃんと登録されたならいっか★
めでたしめでたし。
既存のFlutterプロジェクトのソースをGitHubに保存したい場合はこちら。
それでは!