Vor dem Start sollte ich sagen, ich habe eine Menge Themen (am Ende dieses Posts) über dieses Thema gelesen, aber keine funktioniert für mich oder vielleicht fehlt mir etwas Triviales hier.Wie können zwei verschiedene Github-Konten für zwei verschiedene Repositorys über SSH eingerichtet werden?
Zuerst habe ich das Repository mit HTTPS geklont, aber dann habe ich nach den Dokumenten von here zu SSH gewechselt. Ich habe jeden der SSH-Schlüssel erzeugt und füge sie zu den ssh-agent
hinzu, die den Dokumenten von here folgen.
In wenigen Zeilen (gefälschte Daten verwendet wird, bedeutet ~
mein Home-Verzeichnis) das ist, was ich getan habe:
$ ssh-keygen -t rsa -b 4096 -C "[email protected]"
Enter a file in which to save the key (~/.ssh/id_rsa): [Press enter]
Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]
$ ssh-keygen -t rsa -b 4096 -C "[email protected]"
Enter a file in which to save the key (~/.ssh/id_rsa_second): [Press enter]
Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]
$ eval "$(ssh-agent -s)"
Agent pid 12697
$ ssh-add ~/.ssh/id_rsa
Identity added: ~/.ssh/id_rsa (~/.ssh/id_rsa)
$ ssh-add ~/.ssh/id_rsa_second
Identity added: ~/.ssh/id_rsa_second (~/.ssh/id_rsa_second)
$ ssh-add -l
4096 SHA256:gb+Gn4SqiyAP5ABUsmX6Xz11RHTSvDsWgEE5P2R2VTE ~/.ssh/id_rsa (RSA)
4096 SHA256:yxWMompayDNtYjv5y+FfJl7OpQ5Qu90kPgdXXvx6DRA ~/.ssh/id_rsa_second (RSA)
Der nächste Schritt die ~/.ssh/config
-Datei mit folgendem Inhalt war:
#first account
Host github.com-first
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa
#second account
Host github.com-second
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_second
Ich stoppte hier und versuchen Sie es, indem Sie den SSH-Pub-Schlüssel für id_rsa_second
dem Repository hinzufügen, wo ich es verwenden möchte (das braucht keine Erklärung). Weiter git pull
:
$ git pull
Bad owner or permissions on /home/rperez/.ssh/config
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Dann versuchte ich folgendes:
Ändern der
.git/config
Datei auf die folgenden:[remote "origin"] url = [email protected]:repo/repo.git fetch = +refs/heads/*:refs/remotes/origin/*
Aber es hat nicht funktioniert und durch diese Ich meine, ich habe genau den gleichen Fehler wie zuvor.
Was mache ich falsch? Was ich vermisse?
Was ich habe:
- How to properly configure ssh keys to multiple remote accounts involving github and bitbucket?
- GitHub: Multiple account setup
- Multiple github accounts on the same computer?
- Quick Tip: How to Work with GitHub and Multiple Accounts
- Can't get Multiple SSH keys to work for multiple github accounts
- Multiple SSH Keys settings for different github account
Note: The title may seem confusing but it is correct because it is what I want to achieve I am just talking about one example but at the end I should be able to setup more than one account pointing to different repositories.
Mögliches Duplikat von [ssh config für mehrere bitbucket-Accounts - Einfaches Beispiel, aber das "Remote-Ende wurde unerwartet beendet"] (https://stackoverflow.com/questions/14409761/ssh-config-for-multiple-bitbucket- accounts-simple-example-but-bekommen-remote) – Ikke