LoginSignup
0
0

More than 1 year has passed since last update.

【git】SSHのアクセス条件を指定 (push できなくなったときの対処)

Posted at

はじめに

git のアカウントの切り替えに失敗して、うまくgithub にpush できないときのメモです。

  • .ssh/config
  • git remote SSHの鍵を指定して定義する

ことで無事にpush できました。

内容

症状

休日も自宅で、自分の古いPCで仕事をしています。
作業が終わって、いざGithub にあげようとすると、

$ git push origin2 dev/multiprocessing2
ERROR: Repository not found.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

と言われてしまい、途方にくれていました。土曜日夜の11時。はぁ。

と、この記事を見つけました。

言われる通りに行うと解決しました。

内容

~/.ssh/config
Host host_def_ssh_config
  HostName git.company.com
  User git
  IdentityFile /home/whoever/.ssh/id_rsa.alice
  IdentitiesOnly yes

と鍵が定義されてあるとします。

$ git remote add origin2 git@host_def_ssh_config:officename/repository.git

こうしておいて

$ git push origin2 dev/multiprocessing2

で無事にpush できました。

おわりに

前回も、アカウント切り替えで苦労したことを記事にしましたが、今回でもう解決してくれるとうれしいです。

WEBに集うエンジニアがオープンであることに、また感謝する一日でした。
(2022/05/14)

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