Mosh doesn't provide proper support for agent forwarding, generating error messages like this one:
Permission denied (publickey)
in response to a git clone.
For adressing the issue, follow bellow steps:
- Open an separate SSH session with agent forwarding enabled in another terminal:
ssh -A user@server
- In your mosh session execute the given command for setting SSH_AUTH_SOCK to the last created ssh-agent socket: