Reputation: 994
I use git with ssh-agent on a daily basis on my Mac and it works flawlessly. However, on my remote development server, I should miss something because I can't bypass the prompt for the SSH password when doing remote git operations.
The key is listed in the ssh-agent:
ssh-add -L
:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCktk2+zRYGy0RdM6HJ8JFVPjiNknK7iN8ohdCGSX9fPQ....
/home/user/.ssh/id_rsa.from_user@server_to_git@bitbucket
The key is associated to bitbucket in ~/.ssh/config
:
Host *
IdentitiesOnly yes
ServerAliveInterval 600
ServerAliveCountMax 5
TCPKeepAlive no
IdentitiesOnly yes
Host bitbucket bitbucket.org
User git
Hostname bitbucket.org
KexAlgorithms diffie-hellman-group1-sha1
Identityfile /home/user/.ssh/id_rsa.user@server_to_git@bitbucket
Environment variables export | grep SSH_A
:
SSH_AGENT_PID=30294
SSH_AUTH_SOCK=/tmp/ssh-IS3rVQtFwDxF/agent.30292
Agent is running ps -e | grep -q ssh-agent && echo "SSH Agent is running"
returns
SSH Agent is running
Permissions ls -al ~/.ssh
:
total 48K
drwx------ 2 user user 4,0K oct. 30 18:22 .
drwxr-xr-x 18 user user 4,0K nov. 7 11:52 ..
-rw------- 1 user user 431 mai 10 2016 authorized_keys
lrwxrwxrwx 1 user user 62 oct. 30 16:50 config -> /home/user/.dotfiles/machine-specific/base/ssh/config
-rw------- 1 user user 134 mars 26 2017 environment-
-rw------- 1 user user 137 nov. 7 11:22 environment-server
-rw------- 1 user user 1,8K mai 16 13:38 id_rsa.from_user@server_to_git@bitbucket
-rw-r--r-- 1 user user 2,6K oct. 30 11:02 known_hosts
My "hardened" /etc/ssh/ssh_config
:
AddressFamily inet
BatchMode no
CheckHostIP yes
Ciphers [email protected],[email protected],[email protected],aes256-ctr,aes192-ctr,aes128-ctr
Compression yes
ForwardAgent no
ForwardX11 no
GSSAPIAuthentication no
GSSAPIDelegateCredentials no
Host *
HashKnownHosts yes
SendEnv LANG LC_*
HostbasedAuthentication no
KexAlgorithms [email protected],diffie-hellman-group-exchange-sha256
MACs [email protected],[email protected],[email protected],[email protected],hmac-sha2-512,hmac-sha2-256,hmac-ripemd160
PasswordAuthentication no
PermitLocalCommand no
Port 22
Protocol 2
RSAAuthentication yes
RhostsRSAAuthentication no
StrictHostKeyChecking ask
Tunnel no
Running git clone bitbucket:team/project.git
returns
Enter passphrase for key '/home/user/.ssh/id_rsa.from_user@server_to_git@bitbucket':
Result ssh -v bitbucket
:
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /home/user/.ssh/config
debug1: /home/user/.ssh/config line 1: Applying options for *
debug1: /home/user/.ssh/config line 10: Applying options for bitbucket
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 12: Applying options for *
debug1: Hostname has changed; re-reading configuration
debug1: Reading configuration data /home/user/.ssh/config
debug1: /home/user/.ssh/config line 1: Applying options for *
debug1: /home/user/.ssh/config line 10: Applying options for bitbucket.org
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 12: Applying options for *
debug1: Connecting to bitbucket.org [104.192.143.2] port 22.
debug1: Connection established.
debug1: identity file /home/user/.ssh/id_rsa.from_user@server_to_git@bitbucket type -1
debug1: identity file /home/user/.ssh/id_rsa.from_user@server_to_git@bitbucket-cert type -1
debug1: identity file /home/user/.ssh/id_rsa.from_user@server_to_git@bitbucket type -1
debug1: identity file /home/user/.ssh/id_rsa.from_user@server_to_git@bitbucket-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.8
debug1: Remote protocol version 2.0, remote software version conker_1.0.314-df0526e app-132
debug1: no match: conker_1.0.314-df0526e app-132
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client [email protected] <implicit> none
debug1: kex: client->server [email protected] <implicit> none
debug1: sending SSH2_MSG_KEXDH_INIT
debug1: expecting SSH2_MSG_KEXDH_REPLY
debug1: Server host key: RSA 97:8c:hidden:hidden:....
debug1: Host 'bitbucket.org' is known and matches the RSA host key.
debug1: Found key in /home/user/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
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: Trying private key: /home/user/.ssh/id_rsa.from_user@server_to_git@bitbucket
debug1: key_parse_private2: missing begin marker
debug1: key_parse_private_pem: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
Enter passphrase for key '/home/user/.ssh/id_rsa.from_user@server_to_git@bitbucket':
Any hint ?
Upvotes: 2
Views: 504
Reputation: 994
I just discovered that IdentitiesOnly
needs the public key to be present on the local machine to works.
Upvotes: 1