I connect to my server using SSH:

ssh user@server -p 2224 -zZ abcd

I also have a git repository on my server. The only way I know to clone is:

git clone ssh://user@server.com:2224/path/to/repo

Using the above command I can't connect to my server because -zZ abcd is not in the command. I tried the following commands but doesn't work.

git clone ssh://user@server.com:2224/path/to/repo -zZ abcd

git clone "ssh://user@server.com:2224/path/to/repo -zZ abcd"

How can I include ssh parameters in git-clone command?


You may set up configuration options to save typing; so, after

$ cat >>.git/config <<EOF
[remote "myrepo"]
    url = ssh://user@server.com:2224/path/to/repo -zZ abcd

use just git clone myrepo

See the explanations of the remote..url options in git config for details.


Another possibility is to set per-host ssh options. This can be nice when you want the ssh options to work for all ssh commands and not just for git. These options go in ~/.ssh/config and are documented in man ssh_config. For example, ~/.ssh/config might include something like:

Host server.com
Compression "yes"
ConnectTimeout 4
GlobalKnownHostsFile /path/to/hosts_file

If you regularly use a repository then you should do this using .ssh/config like amcnabb says, remember that .ssh/config lets you make aliases for configuration options, or maybe .git/config if that's inappropriate for some reason.

If however you must pass ssh really transient config options, like because you're stuck at an airport wifi which blocks ssh, then adapt my usual instructions for ssh over tor :

Install connect in your path, maybe by building connect.c from source

Create a script called git-tbb :

exec ssh -o ProxyCommand="connect -5 -S %h %p" $*

Create a script called git-tbb

export GIT_SSH=`which ssh-tbb` git pull
exec git $*

Rename them to -tor if you change the port to 9050 for the default tor config, as opposed to TBB's default 9150.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.