I created a script to create remote repositories on github and in case the machine has more than one user who access the script to create remote repositories and for that I need a github token key I created the token key at Token Github and created the key for SSH access on github with the following command:
Account github.com/usuario1
linuxuser@linuxmint$ ssh-keygen -t rsa -b 4096 -C "[email protected]"
/home/linuxuser/.ssh/id_rsa_hotmail_github_usuario1
getting like below:
Enter file in which to save the key (/home/linuxuser/.ssh/id_rsa): /home/linuxuser/.ssh/id_rsa_hotmail_github_usuario1
Account github.com/usuario2
linuxuser@linuxmint$ ssh-keygen -t rsa -b 4096 -C "[email protected]"
/home/linuxuser/.ssh/id_rsa_yahoo_github_usuario2
getting like below:
Enter file in which to save the key (/home/linuxuser/.ssh/id_rsa): /home/linuxuser/.ssh/id_rsa_yahoo_github_usuario2
List keys ssh
ls -a ~/.ssh/
id_rsa_hotmail_github_usuario1 id_rsa_hotmail_github_usuario1.pub
id_rsa_yahoo_github_usuario2 id_rsa_yahoo_github_usuario2.pub
I copied and put each key in your account. I'm logged into my linux user where the keys were created
In the script I changed the vector of users putting the users from github leaving it as:
USUARIOS_GIT=("usuario1" "usuario2" "github_usuario3")
and the vector of the tokens I put the token of each github user
CHAVE_TOKEN=("dhkssklfhfkh" "kfhfflhd" "chave_token_github_usuario3")
that is, there are two github accounts in which I have to create remote repositories with the script logged into my machine with the user linuxuser
linuxuser@linuxmint/Developement$ gitpratico usuario1 projeto1
it shows the error below:
git push [email protected]:usuario1/projeto1.git master
ERROR: Permission to usuario1/projeto1.git denied to usuario2.
creates an empty repository but won't let me make any changes or commits after that not uploading the repository files to github.com/usuario1 it looks like it's trying to access usuario2
who owns the yahoo account.
For example, if a company machine has only one user and this machine is accessed by up to three people at different times with the same machine user and they need to use the script to create remote repositories in different github users, it presents this problem by creating the empty remote repositories and not letting any commits be made.
How do I solve this problem to be able to create repositories in different accounts without having to log in to another linux user?
Script being used to create remote repositories under different github users Script gitpratico_multiuser
I did exactly this configuration using only my user and even so it creates the empty repository not adding the files that exist in the project folder.
My file ~/.ssh/config this
# Default GitHub user (usuario1)
Host github-hotmail
HostName github.com
IdentityFile ~/.ssh/id_rsa_hotmail_github_usuario1
IdentitiesOnly yes
User git
# Github user (usuario2)
Host github-yahoo
HostName github.com
IdentityFile ~/.ssh/id_rsa_yahoo_github_usuario2
IdentitiesOnly yes
User git
Add ssh private keys to your agent:
$ ssh-add ~/.ssh/id_rsa_yahoo_github_usuario1
$ ssh-add ~/.ssh/id_rsa_yahoo_github_usuario2
testing the connection
in user1
$ ssh -T git@github-hotmail
Hi usuario1! You've successfully authenticated, but GitHub does not provide shell access.
in user2
$ ssh -T git@github-yahoo
Hi usuario2! You've successfully authenticated, but GitHub does not provide shell access.
When typing gitpratico_multiuser user1 <repository1>
if i type git status
it does not show that there are files to be uploaded
and when i type:
When typing gitpratico_multiuser user2 <repository2>
shows the table below:
ERROR: Permission to usuario2/repository2.git denied to usuario1.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
but I still have another problem when I log in another linux user and put the settings below:
root@linuxmint# login linuxuser2
userlinux2@linuxmint$ mkdir .ssh
userlinux2@linuxmint$ nano ~/.ssh/config
# Default GitHub user (user1)
github-hotmail host
HostName github.com
IdentityFile /home/userlinux1/.ssh/id_rsa_hotmail_github_usuario1
Identities Only yes
User git
# Github user (user2)
github-yahoo host
HostName github.com
IdentityFile /home/userlinux1/.ssh/id_rsa_yahoo_github_usuario2
Identities Only yes
User git
linuxuser2@linuxmint$ sudo ssh-add /home/userlinux1/.ssh/id_rsa_yahoo_github_user2
[sudo] senha para linuxuser2:
Could not open a connection to your authentication agent.
linuxuser2@linuxmint$ sudo ssh-add /home/userlinux2/.ssh/id_rsa_hotmail_github_usuario1
[sudo] senha para linuxuser2:
Could not open a connection to your authentication agent.
I can't create repositories for github user1 and user2 logged into another linux user, I tried to create the .ssh folder and copy the private keys to linuxuser2
but I also didn't get results how can I solve this problem I searched and didn't find anything to regarding how to use the same key of github_usuario1
and github_usario2
created in userlinux1 in another different linuxuser2.
How can I solve this problem?