2

I have started using my Windows 10 for Rails development and am using Linux subsystem for the same.

Recently I faced an issue connecting to a remote machine via SSH from the terminal. The public key is already available on the remote machine.

After doing some troubleshooting based on the resources I found on web I noticed that SSH agent was not running because ssh-add -l command didn't provided the expected output.

To make the SSH agent launch on startup I followed the instructions at https://github.com/abergs/ubuntuonwindows#2-start-an-bash-ssh-agent-on-launch and it worked flawlessly.

Now that SSH agent launches automatically I added my identity file to it using command ssh-add path/to/identity/file..

Note that while generating SSH keys I used custom file name id_work_gmail and id_work_gmail.pub. Thus I had to add it to the agent using above command.

After doing that I can successfully connect to remote machine through SSH.

Until this everything was going smooth. However as soon as I closed each of the Cmder Ubuntu Bash consoles and started a new one ssh-add -l informed The agent has no identities.. So again I had to add my custom-named identity file to the agent.

So this is something I need to do every-time I kill each of the Ubuntu Bash consoles and start a fresh one.

My question is how can we make the ssh-add path/to/identity/file/custom-named action persistent like it happens on actual Ubuntu machine. And am curious to know what is it that makes it a one-time activity on Ubuntu machine and a repeated activity on Windows 10 Linux Subsystem.

Thanks.

1 Answer 1

1

And am curious to know what is it that makes it a one-time activity on Ubuntu machine and a repeated activity on Windows 10 Linux Subsystem.

Normally, the ssh-agent runs in your session so it does not close earlier than you logout from your account in Linux.

If you use it from WLS and close the (probably) last window, it does reasonable cleanup and probably stops your ssh-agent, which is reasonable and safe to remove sensitive data from memory.

My question is how can we make the ssh-add path/to/identity/file/custom-named action persistent like it happens on actual Ubuntu machine.

Just do not close that window (or leave one opened on background ... it might help too). Or configure ssh to do that step automatically when you use the key for the first time. Just write to your ~/.ssh/config

Host server-you-are-connecting.to
  IdentityFile path/to/identity/file/custom-named
  AddKeysToAgent yes
8
  • Thanks for the elaborate answer. Your suggestion of using option AddIdentityToAgent yes resulted in Bad configuration option: addidentitytoagent. I referred the manual at linux.die.net/man/5/ssh_config and there I could not find that option in supported options and hence I guess this error. Commented Aug 8, 2017 at 6:47
  • Sorry. I meant AddKeysToAgent inestead.
    – Jakuje
    Commented Aug 8, 2017 at 6:48
  • same error Bad configuration option: addkeystoagent Commented Aug 8, 2017 at 6:50
  • Then you have old OpenSSH (it works with 7.2 and newer), so either update or go with the first option.
    – Jakuje
    Commented Aug 8, 2017 at 6:51
  • Thanks I will try to update it. BTW I also found a related SO Post unix.stackexchange.com/a/269132/146438 on that option. Commented Aug 8, 2017 at 6:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .