I have set the Github passwordless login as below.
ssh-keygen -t rsa -P ''
cat .ssh/id_rsa.pub |xclip
I pasted the public key into ssh and gpg keys on the Github site.
git init
git config --global user.name "someone"
git config --global user.email "[email protected]"
git config remote.origin.url git+ssh://[email protected]/someone/newstart.git
ssh -T [email protected]
git clone git+ssh://[email protected]/someone/newstart.git /tmp/newstart
The above works.
Now I want to use a different key name for Github instead of its default name id_rsa.
ssh-keygen -t rsa -P '' -f .ssh/id_rsa.github
cat .ssh/id_rsa.github.pub |xclip
I pasted the new pub key into ssh and gpg keys on the Github site.
git init
git config --global user.name "someone"
git config --global user.email "[email protected]"
git config remote.origin.url git+ssh://[email protected]/someone/newstart.git
ssh -T [email protected]
The above does not work.
git clone git+ssh://[email protected]/someone/newstart.git /tmp/newstart
The above also does not work.
ssh -i .ssh/id_rsa.github -T [email protected]
The command above can connect to Github successfully, but I can't type the following command to clone the repository.
git clone -i .ssh/id_rsa.github git+ssh://[email protected]/someone/newstart.git /tmp/newstart
Can't I use a pub key with another name, such as id_rsa.github instead of the default name id_rsa?
You can use key with any name. But you should set it explicitly when making ssh connection.
Multiple keys If there is already id_rsa file on the second computer, it is possible to rename the key to something else and then specify the key name when making an SSH connection.
Linux/Mac Instructions: ssh/ directory by default, including your private key, but you may specify a direct location. Never share your private key.
You need to tell SSH to use this key for Github. Put this in ~/.ssh/config
:
Host github.com
IdentityFile ~/.ssh/id_rsa.github
User git
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With