I've been looking for a solution on how I can use multiple ssh keys and I figured out, that it will work with a config file in the .ssh directory, but it doesn't work on windows.
My problem is that I'm using a private key to access a git server, so it looks like this: ssh://[email protected]/directory , it works fine when I'm using TortoiseGit, 'cause there is a possibility to choose the private key.
But I want to use the git rep in my IntelliJ IDEA and there is just the option to use the git native shell and it also works, if I put the key, called id_rsa ,into the .ssh folder. Now I want to use multiple ssh keys (so my key will get the name "id_rsa_test", so how do I configure the .ssh/config file under Windows, that it works with a usual git server?
The most examples I found yet are just for the use with github.
The SSH server has its own set of configuration files, including the SSH server system-wide configuration file named sshd_config. By default, these files reside in the /etc/ssh directory on the remote host.
Yes, Git for Windows installs its own SSH client. It ships a version of OpenSSH with the package. If you're seeing /usr/bin/ssh when you run command -v ssh , then you're using the version from Git for Windows.
If you use "Git for Windows"
>cd c:\Program Files\Git\etc\ssh\
add to ssh_config following:
AddKeysToAgent yes IdentityFile ~/.ssh/id_rsa IdentityFile ~/.ssh/id_rsa_test
ps. you need ssh version >= 7.2 (date of release 2016-02-28)
You can use multiple ssh keys on Windows 10 and specify the type of access allowed.
Assuming you have created the ssh secure keys already and they were stored in C:\Users\[User]\.ssh
Open the folder C:\Users\[User]\.ssh
Create the file config
(no file extension)
Open the file in a text editor like Notepad, and add these configuration details for the first remote host and user. Keep both CMD and BASH paths or only pick one format. Then copy-and-paste below it for the other host/user combinations and amend as required. Save the file.
Host [git.domain.com] User [user] Port [number] IdentitiesOnly=yes PreferredAuthentications publickey PasswordAuthentication no # CMD IdentityFile C:\Users\[User]\.ssh\[name_of_PRIVATE_key_file] # BASH IdentityFile /c/Users/[User]/.ssh/[name_of_PRIVATE_key_file]
Testing
$ ssh -T git@[git.domain.com] Welcome to GitLab, @[User]!
C:\Users\[User]>ssh -T git@[git.domain.com] Welcome to GitLab, @[User]!
ssh -Tv git@[git.domain.com]
(or -Tvv
or -Tvvv
for higher verbosity levels).If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With