Problem:
i need to verify git repo properties (ssh key,repo url) in ruby solutions:
1) write ssh key into ~/.ssh/id_rsa
file and execute git clone
command with repo url property - easiest way
- cause race conditions when multiple users trying to check theirs repos.
2) write key into any file and link server and key in ssh.config
file than execute git in ordinal way
-ssh.config
file has limited lenght(255 records)
3) add key via ssh-agent
and execute git in ordinal way
- ruby can't handle passphrase request (if ssh key protected with passphrase)
Resume:
so i need universal solution (like ssh -i
) that is easy to use,clean,will work in multithread environment and all开发者_如何学编程 errors can be handled via basic IO (exec and so on)
Perhaps you could use the GIT_SSH
environment variable to make git use your own SSH wrapper. That script could look at additional environment variables and invoke ssh
with the appropriate options.
精彩评论