免責聲明

Disclaimer (免責聲明)
繼續閱覽代表您接受以上的免責聲明.
To continue reading means you accept the above disclaimer.

2015年3月12日 星期四

How to tell git which private key to use for ssh-git docker container


//=== http://superuser.com/questions/232373/how-to-tell-git-which-private-key-to-use
[Q] how to tell git which private key to use?

* edit ~/.ssh/config to add the host-key mapping for git server
[
Hostname git-server-ip-or-hostname
IdentityFile path-to-private-key
]

* Write a script that calls ssh with -i path-to-priv-key, and place script filename in $GIT_SSH. ???

* use ssh-agent to temporary authorize a private key.

??? ssh-agent sh -c 'ssh-add path-to-priv-key; git fetch user@git-sever'

$ ssh-add path-to-priv-key
[err] Could not open a connection to your authentication agent.


//=== http://stackoverflow.com/questions/17846529/could-not-open-a-connection-to-your-authentication-agent/20403535

-->
using CentOS.
$ exec ssh-agent bash

--> git bash
$ eval $(ssh-agent)

$ ssh-add path-to-priv-key
$ ssh -v git@container-ip
git> create mygitssh


//=== after create a repository mygitssh.git on git-server
[
$ git clone git@container-ip:mygitssh.git
...
$ git add .
$ git push origin master
]

or

[
$ git init
...
$ git add .

$ git remote add origin git@container-ip:mygitssh.git
$ git commit -m "init"
]


沒有留言:

張貼留言