i want to know if there is a way to use my local ssh keys to access a git server from a third remote machine. In example: Imagine we have three computers: PC1, PC2 and GITSERVER.
I have my ssh keys stored on PC1 which are authorized on GITSERVER, from PC1 i ssh to PC2 from where i want to clone a repository stored on GITSERVER.
There is a way to do that without copying my private key or creating a new one?
As Sajib Khan states, a ssh_config file can help you. However, then you are always taking your private key with you. There may be use cases in which you don't want to use your private key on a remote machine. For this, you can define per host if you want to take your key with you to the remote machine:
Another way to implement this: You can start the
ssh-agent
and add the key to it, which could be done in your.bashrc
:This helps you so that you don't have to enter your password whenever you start a ssh session. You can take your ssh key from your local machine to another machine for one connection with this command: