How To Specify Ssh Keys When Running Shell Command Like Git,Rsync – POFTUT

How To Specify Ssh Keys When Running Shell Command Like Git,Rsync


I have a remote repository which is Git. I want to connect to Git over ssh because there are problems with the firewall rules in our work environment. How can use ssh to connect remotely to Git with specifying ssh keys for this Git operations.

Using  ssh-agent

ssh-agent will create and temprorary environment where tkey is added with ssh-add command into the shell. After environment is completed git operations can be done where git will use current ssh keys to connect remotely with ssh tunnel. Keep in mind the keys will be lost after commands are completed

ssh-agent $(ssh-add /home/ismail/ssh_keys/ismail; \
 git clone git@github.com:ibaydan/dev.git)

With Host Configuration

Another way to connect remote Git Repository over ssh is using ssh configuration files to specify IdentityFile like below

Host github.com
    IdentityFile ~/.ssh/github_rsa

This will work too. When connecting to github.com specified IdentityFile will be used by ssh.

 

How To Specify Ssh Keys When Running Shell Command Like Git,Rsync Infografic

How To Specify Ssh Keys When Running Shell Command Like Git,Rsync
How To Specify Ssh Keys When Running Shell Command Like Git,Rsync

LEARN MORE  What Is TPM? Manufacturing, Management and Maintenance Of TPM

Leave a Comment