Bash function hangs while command run perfectly without function
You have a recursive error. You define a function called 'ssh' then call the same function in your function. This results in a recursive loop.
Specify the absolute path to the ssh
binary and that should fix it.