Permission denied (publickey) while using SSH connection

Hi, I just installed Gitlab on a VBox machine running Ubuntu 16.04.1, generated a new ssh key, added it to the user, created a repo on Gitlab’s site and when trying to clone the repo to client’s machine i keep getting the error “Permission denied (publickey)”. I’ve noticed that the authorized_keys is stored in /var/opt/gitlab/.ssh folder. Could that be the problem?

Here is what i’ve tried on client’s side (Win7 machine) using Git Bash:

[code]username@usernamePC MINGW64 ~
eval "(ssh-agent -s)"
Agent pid 2292

username@usernamePC MINGW64 ~
$ ssh-add ~/.ssh/id_rsa
Identity added: /c/Users/username/.ssh/id_rsa (/c/Users/username/.ssh/id_rsa)

username@usernamePC MINGW64 ~
$ ssh-add -l -E md5
2048 MD5:e4:05:be:66:ce:c1:5d:a2:33:60:c9:c5:0c:67:5f:c7 /c/Users/username/.ssh/id_rsa (RSA)

username@usernamePC MINGW64 ~
$ ssh-agent -s
SSH_AUTH_SOCK=/tmp/ssh-MyztbEvFTXKM/agent.1280; export SSH_AUTH_SOCK;
SSH_AGENT_PID=7324; export SSH_AGENT_PID;
echo Agent pid 7324;

username@usernamePC MINGW64 ~
$ ssh -vT git@192.168.170.2
OpenSSH_7.1p2, OpenSSL 1.0.2g 1 Mar 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to 192.168.170.2 [192.168.170.2] port 22.
debug1: Connection established.
debug1: identity file /c/Users/username/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/username/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/username/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/username/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/username/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/username/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/username/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/username/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.2p2 Ubuntu-4ubuntu2.1
debug1: match: OpenSSH_7.2p2 Ubuntu-4ubuntu2.1 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 192.168.170.2:22 as ‘git’
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client chacha20-poly1305@openssh.com none
debug1: kex: client->server chacha20-poly1305@openssh.com none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:z3D6tZgSMixu6hiku0C81T2etxzbA66j2eQoJDx482Q
debug1: Host ‘192.168.170.2’ is known and matches the ECDSA host key.
debug1: Found key in /c/Users/username/.ssh/known_hosts:1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /c/Users/username/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: /c/Users/username/.ssh/id_dsa
debug1: Trying private key: /c/Users/username/.ssh/id_ecdsa
debug1: Trying private key: /c/Users/username/.ssh/id_ed25519
debug1: No more authentication methods to try.
Permission denied (publickey).

username@usernamePC MINGW64 ~
$ git clone git@192.168.170.2:username/test-project-02.git
Cloning into ‘test-project-02’…
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.[/code]

I got it to work.

Previously, before installing gitlab i’ve installed and set up openssh changing the /etc/ssh/sshd_config file. Seems like one of the following settings was to blame.

PermitRootLogin no
PasswordAuthentication no
UsePAM no

So i didn’t bother setting up ssh this time, started from scratch let it use the default install and everything is allright now.

So I don’t really understand here. Is it the config you -had- or the config you -have- to get it working?
Al