I had built a kali-rolling VM in V-sphere while back which I use for my main box, and have set up SSH keys for access to that machine (using puttygen) from my windows machine so I can copy files back and forth easily and securely. So far so easy.

The problem came about when I set up a second, portable Kali install on my Mac that could be taken to client sites. I set up SSH access between these two boxes, and noticed some bizarre behaviour. On the Vsphere VM, when attempting to SSH to Mac VM, I would see the gnome-keyring window (looks a bit like this: https://intra.sismo.ipgp.fr/ssh-keys...e-xfce-desktop), where it would ask for the passphrase and unlock the SSH keys for that session.

However, the Mac VM would never do this, and ask for the passphrase on every connection attempt. It was a little similar to this problem: https://askubuntu.com/questions/3622...assphrase-once , which I found after investigating the sshd_config on both boxes to ensure that they were the same, checking pam.d configs, checking gnome-keyrings was present and updated and the daemon running on both and so on. I needed a workaround. The solution presented there wasn't ideal, as the daemon was already running, so a PID check wouldn't work. So I hacked together this horrible little kludge, I'm sure it could be more pretty (comments welcome), but it seems to work all the time now. The basic idea was create function that would add the key, but also make it permanent (r pseudo-permanent, anyway ) by creating an empty file when the addkey function ran. Then created a delete file script in /etc/init.d and symlinked it in rc5.d so that the file would be deleted on reboot/restart when the GUI started.

in .bashrc, create a new function and add a test:

addkey() {
ssh-add ~/.ssh/id_rsa &>/dev/null
}

if [ -f /$HOME/.ssh/logged ]; then
:
else
touch/$HOME/.ssh/logged
addkey
fi

create /etc/init.d/remfile:

#!/bin/bash

if [ -f /$HOME/.ssh/logged ]; then
rm /$HOME/.ssh/logged
else
:
fi

in /etc/init.d:

$ln -s ../init.d/remfile ../rc5.d/S01remfile

Hope this helps someone