ConEmu, cygwin/msys and ssh-agent
When you ssh into remote computer you may use your ‘Public key’ for authentication. Private and public keys are usually stored in the user’s home directory and are often encrypted with passphrase to be more secure.
Some tools may pick up public keys automatically, some others require special switch to select key authentication mode. The example is shown below.
ssh -i $HOME/.ssh/id_rsa your.server.com
To avoid typing the passphrase each time you connect any remote system you may run ssh-agent which will ‘cache’ your keys in memory for use in the current session.
By the way, if you need to run some command after logging into remote system
you may append it to
ssh arguments. For example you may set startup (working)
directory for the remote ssh session as follows.
ssh your.server.com "cd /path/to/directory ; bash --login"
- How ssh-agent works
- Some other links
How ssh-agent works
On Unix systems or in cygwin ssh-agent may be started as follows:
eval $(ssh-agent) # Create agent and environment variables
That would be nice if you are working in the single-tab console environment, but what about ConEmu and multi-tab environment?
Answer 1: Export variables
eval $(ssh-agent) # Create agent and environment variables ConEmuC -export=ALL SSH_* # Export variables to ConEmu and all its tabs
The only drawback is a limitation of the implemented export method - existing cygwin tabs will not get these variables, only new cygwin consoles will get them.
Answer 2: Modify your bash profile
GitHub documentation suggests to change your bash profile, so your ssh-agent will be initialized properly in any bash instance, regardless of the used terminal.
Also, here you may find slightly modified script, which adds ssh key files by mask.
Some other links
SSH agent working with @ConEmuMaximus5 and Git Bash. For multiple tabs. Load your keys just once, use everywhere.
Using the bash script and an alias
This solution does not relates to ConEmu at first glance but may be useful anyway.