您不能在GIT_SSH
环境变量中提供选项;从git
手册页:
GIT_SSH
If this environment variable is set then git fetch and git push will use this command instead of ssh when they need to connect
to a remote system. The $GIT_SSH command will be given exactly two arguments: the username@host (or just host) from the URL
and the shell command to execute on that remote system.
To pass options to the program that you want to list in GIT_SSH you will need to wrap the program and options into a shell
script, then set GIT_SSH to refer to the shell script.
.ssh/config
一种选择是使用适当的配置将节添加到您的文件中:
Host bitbucket.org
StrictHostKeyChecking no
IdentityFile /home/me/my_private_key
另一种选择是指向GIT_SSH
执行所需操作的 shell 脚本。例如,在 中/home/me/bin/bitbucket_ssh
,输入:
#!/bin/sh
exec /usr/bin/ssh -o StrictHostKeyChecking=no -i /home/me/my_private_key "$@"
然后GIT_SSH
指向/home/me/bin/bitbucket_ssh
。
我更喜欢.ssh/config
尽可能使用,因为这避免了为每个远程创建每个目标脚本的需要。