Search code examples
gitpowershellssh-keygen

Using Powershell open and pass values to Git Bash


I am creating a powershell script to easily a group of tools include git. I have install git but the problem is I need to open the git bash prompt and pass in a command that will generate SSH keys.

How can I open the git bash prompt and pass the desired values?


Solution

  • If you are not protecting your private key with a passphrase, you could use Powershell directly to call ssh-keygen, without having to call the git bash first.

    See for instance "automate ssh-keygen for github in powershell":

    # Create your GitHub SSH Key
    $MyEmailAddress = "some.user@github.com"
    if (! (Test-Path  ("~/.ssh/id_rsa_test"))){
        ssh-keygen -t rsa -C "$MyEmailAddress" -f "id_rsa_test" -P """"
    
    }