Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6150199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:35:04+00:00 2026-05-23T19:35:04+00:00

I’m attempting to write a batch script to clone a bunch of repositories. My

  • 0

I’m attempting to write a batch script to clone a bunch of repositories. My problem is that the user has a password protected ssh key. So each time I run call git clone blah@blah/blah.git in my batch file I have to input the users password. I know I can get the password from them as set \p userpwd=[Enter ssh pwd] but how do I pass this to each call?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T19:35:04+00:00Added an answer on May 23, 2026 at 7:35 pm

    Here is a way to acheive the same effect, but with different steps than what you hinted in your question:

    1. Start ssh-agent
    2. Add your key with ssh-add (it will ask for the password, just once)
    3. Launch as many git clone <url> as you need
    4. Clean up

    Step two will ask for a password, instead of using set /p. The following batch file is somewhat of a port of github’s ssh key guidelines. I tested it with a ssh connection to gitorious, running git version 1.7.6.msysgit.0 under cmd.exe in Windows Vista.

    @rem Do not use "echo off" to not affect any child calls.
    @setlocal
    
    @:: Find out where is git installed
    @where git > __wheregit.txt
    
    @:: Under XP, there is no where command. Use this (thanks to Raymond Chen)
    @:: http://blogs.msdn.com/b/oldnewthing/archive/2005/01/20/357225.aspx
    @:: (for %%e in (%PATHEXT%) do @for %%i in (git%%e) do @if NOT "%%~$PATH:i"=="" echo %%~$PATH:i) > __wheregit.txt
    
    @:: Move it to a environment variable, we will need to manipulate the string
    @set /p wheregit= <__wheregit.txt
    @del __wheregit.txt
    
    @:: Parse the full file name of git.cmd to find the the path
    @for /F "delims=" %%I in ("%wheregit:~0,-7%..") do @set git_install_root=%%~fI
    @set PATH=%git_install_root%\bin;%git_install_root%\mingw\bin;%PATH%
    
    @:: The keys are in the home directory.
    @if not exist "%HOME%" @set HOME=%HOMEDRIVE%%HOMEPATH%
    @if not exist "%HOME%" @set HOME=%USERPROFILE%
    
    @ ::start ssh-agent, and save its output
    @ssh-agent > __ssh-agent.out
    
    @ ::parse the output and set environment vars needed by ssh-add
    @FOR /F "eol=; tokens=1* delims=;" %%i in ('findstr /v echo __ssh-agent.out') do @set %%i
    @del __ssh-agent.out
    
    @ ::add the key to the agent (this will ask for the password)
    @ssh-add %HOME%\.ssh\id_rsa
    
    @ ::Call git. When it's time to use the key, its password will be provided by ssh-agent
    @ ::Obviously you will put your git clone url here
    @call git clone git@gitorious.org:siaki-sso/siaki-sp.git
    @call git clone git@gitorious.org:siaki-sso/siaki-idp.git
    
    @ ::Kill ssh-agent
    @ssh-agent -k
    
    @endlocal
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to clean up various Word 'smart' characters in user input, including but
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
i want to parse a xhtml file and display in UITableView. what is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.