While marked answer is 100% correct I use a bit different approach. For ssh connections using OpenSSH client I utilze ProxyCommand for *.onion sites in the following way:
ProxyCommand socat STDIO SOCKS4A:<tor socks hostname or IP>:%h:%p,socksport=9050
This should also be the only change needed for git ssh ...
torsocks is the way to go. You may need to install it separately from Tor if it is not installed automatically.
Make sure Tor is running: systemctl status tor
Run your command through torsocks: torsock git pull or torsocks ssh abcxyz.onion
Another option is to run torsocks --shell. This will make all commands in that shell automatically run through Tor. ...
Both of your questions are addressed by the Tor Project FAQ:
Right now the path length is hard-coded at 3 plus the number of nodes
in your path that are sensitive. That is, in normal cases it's 3, but
for example if you're accessing an onion service or a ".exit" address
it could be 4.
We don't want to encourage people to use paths longer than ...
Onion services require seven hops because it is important that nobody, not even the rendezvous point, is able to deanonymise either the client or service, even in the presence of adversaries controlling any one point. The three-hops-from-client-to-service design you hypothesise cannot, by currently-known methods, be made secure for both client and service ...
It is inevitable that there will be some adversarial hosts in a network like Tor. Nation state actors, security researchers and others are running hosts with a variety of motives, but often with the primary goal of de-anonymizing either specific persons or just anyone. In a network of N intermediaries where your connection goes through M hosts, there is a 1/...
According to this FAQ from the EFF, Freedom Host had a publicly visible IP address that allowed the FBI to physically seize their server:
In December 2014, the FBI received a tip from a foreign law
enforcement agency that a Tor Hidden Service site called “Playpen” was
hosting child pornography and that its actual IP address was publicly
visible and ...