Thursday, May 16, 2024
 Popular · Latest · Hot · Upcoming
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 6606  / 1 Year ago, sat, april 8, 2023, 5:32:10

Please help me understand how to install ssh keychain on my Ubuntu under WSL in order for me to be able to configure my .ssh/config file to use key chain. I've tried editing my config file that I created myself in my .ssh folder to add Usekeychain but it does not recognise that as a command.


I tried uninstalling my ssh server and re-installing it manually but nothing changed. I just got stuck in adding my private/public key to my keychain ever since.


The whole essence of what I'm doing is to be able to connect to my server from my private computer without having to add my private key each time I want to login to my server but I'm stuck on how to go about it. Where I'm learning from online the person has his config file set up like:


Host*
AddKeysToAgent Yes
UseKeychain Yes
IdentityFile ~/.ssh/[his githubfile]

Then I tried putting that in my config file, but when I tried login in to my server it said UseKeychain is not a command. Since then, I've since been trying to find how to add my key to my keychain and how to setup my config file. Until I encountered this problem, I had been able to setup my server and connect to it by installing my private key in the server each time I connect to it.


I just don't know how to go about adding my key to the keychain and how to setup my ssh config file to be automated. My teacher on front-end masters is using Metatron CLI.


I'm just confused and stressed. My first time on backend and it's becoming really frustrating, from one issue to another. My previous issues were because I'm using WSL.


Please help me on this. Thanks!


More From » server

 Answers
0

Part of your problem, at least, is that UseKeychain is a MacOS-specific configuration option which instructs it to add the unlocked key to the MacOS Keychain (part of that OS that can store it securely). So we can assume that your instructor is on a Mac. It sounds like the Mac version of ssh will read the OS keychain, which is typically unlocked on first use across the whole OS. My understanding is that there are equivalents under Ubuntu, like Gnome Keyring, but this won't work under WSL.


So let's start with the fact that you'll need to remove that MacOS-specific configuration option under Ubuntu, at least.


If your instructor is providing that config file to students as an example, they really should do it properly with:


Host*
IgnoreUnknown UseKeychain
AddKeysToAgent Yes
UseKeychain Yes
IdentityFile ~/.ssh/[his githubfile]

That would allow it to work both on a Mac as well as the (90%+) rest of the world.


Under WSL Ubuntu, you will need to enter the passphrase at least once in each session to add it to ssh-agent. If you run multiple shell instances, you'll typically need a new ssh-agent invocation in each shell.


Alternatively, you can install Funtoo keychain which can (more) easily set up the connection to ssh-agent in each shell instance. This can allow you to only need to enter the passphrase once as long as the WSL instance is working.


sudo apt-get install keychain

And add something like the following to your ~/.bashrc:


eval `keychain --eval --agents ssh id_rsa`

See the official keychain website for full instructions.


Please note, once the WSL Ubuntu instance terminates (wsl -l -v shows "Stopped") then the passphrase will need to be entered again on next use.


[#1280] Sunday, April 9, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rofity

Total Points: 182
Total Questions: 98
Total Answers: 115

Location: Albania
Member since Sat, Jan 7, 2023
1 Year ago
rofity questions
Mon, Apr 25, 22, 12:28, 2 Years ago
Tue, Jul 5, 22, 16:53, 2 Years ago
Mon, May 10, 21, 22:51, 3 Years ago
Tue, May 17, 22, 02:46, 2 Years ago
;