Skip to content

Latest commit

 

History

History
52 lines (44 loc) · 2.92 KB

git-ssh-windows-vscode-config.md

File metadata and controls

52 lines (44 loc) · 2.92 KB

Using a ~/.ssh/config File for Git Bash and PowerShell on VS Code in Windows

1. Open VS Code and Git Bash

  • Open VS Code and press Ctrl + Shift + P to open the command palette.
  • Type and select "Terminal: Select Default Profile".
  • Choose "Git Bash" from the list of available profiles.

2. Create a ~/.ssh/config File

  • In the terminal, navigate to the ~/.ssh directory by running the following command:
cd ~/.ssh
  • Create a new config file by running the following command:
touch config

3. Configure SSH Settings for Multiple Hosts

  • Open the config file in a text editor, such as Notepad or VS Code.
  • Add your SSH settings for multiple hosts to the file. For example, to use different identity files for Bitbucket and GitHub, you can add the following lines:
Host bitbucket.org
    IdentityFile ~/.ssh/id_ed25519_bitbucket

Host github.com
    IdentityFile ~/.ssh/id_ed25519_github

Make sure to replace ~/.ssh/id_ed25519_bitbucket and ~/.ssh/id_ed25519_github with the paths to your identity files.

  • You can also add other common SSH settings, such as changing the default port or enabling connection multiplexing. For example:
Host example.com
    Port 2222
    ControlMaster auto
    ControlPath ~/.ssh/sockets/%r@%h-%p
    ControlPersist 600

Make sure to replace example.com with the actual hostname and adjust the settings as needed.

  • Save and close the config file.

4. Use SSH in Git Bash and PowerShell

  • You can now use SSH in both Git Bash and PowerShell with the settings specified in your ~/.ssh/config file.
  • To test the configuration, open a new terminal in VS Code and select either "Git Bash" or "PowerShell" as the default profile.
  • Run an SSH command, such as ssh bitbucket.org, and verify that it uses the settings specified in your config file.

We hope that these resources will be helpful to you as you continue to use Git SSH with VS Code in Windows. 😊 That's it! You have successfully set up a ~/.ssh/config file for both Git Bash and PowerShell on VS Code in Windows, with multiple hosts and additional configuration examples. 😊

Additional Resources

For more information on using the ~/.ssh/config file to manage SSH connections, you can refer to the official documentation from GitHub and Bitbucket: