I would like to use 1 command - 'git clone...' but with passphrase using SSH. Is it possible ? I want to make a script which clone repository so I have to give my passphrase as a parameter. (I cant use ssh-agent)
Asked
Active
Viewed 392 times
0
-
1https://stackoverflow.com/a/34169584/341994 – matt Dec 07 '20 at 15:20
-
Your question is off topic. This site is for assistance with issues from your provided code attempt at performing a specific task. It is not where you ask for the code to perform that task, which is essentially just research. Please research the task and write the code before asking for assistance with it. We have an excellent search facility at the top of each page, which should provide you with sufficient code for you to adapt into that code attempt yourself. – Compo Dec 08 '20 at 14:17
1 Answers
1
You could use a simple batch file
ssh_ask.bat
@echo off
echo [my-passphrase]
Then you have to set two variables (usefull in another batch file)
prepare.bat
set display=0
set "SSH_ASKPASS=C:\\path\\to\\ssh_ask.bat"
Now ssh will ask the batch file for the passphrase

jeb
- 78,592
- 17
- 171
- 225
-
to be honest I don't undestand, so this is 1 file with 4 line of code ? or 2 file ? where i should 'git clone' and in which order ? – discCard Dec 08 '20 at 10:00
-
-
ok,thanks, so we have 2 file, but in which of this 2 file i should put line with 'git clone' ? – discCard Dec 08 '20 at 13:42
-
@discCard You don't need to put `git clone` into the batch files. Just start the `prepare.bat` once. After that, yxou can use git clone from the console without asking for the passphrase – jeb Dec 08 '20 at 15:01
-
after run prepare.bat I'm still getting ask for passphrase :( What is SSH_ASKPASS ? this is system variable ? I don't understand why this should works – discCard Dec 08 '20 at 15:27
-
@discCard With the SSH_ASKPASS variable, the ssh program knows that it should start the program in the SSH_ASKPASS variable instead of asking the user (only when the DISPLAY variable is also set). Did you modify the `C:\\path\\to\\ssh_ask.bat` to YOUR real path? – jeb Dec 08 '20 at 18:39
-
yes, I wrote my true path to ssh_ash.bat and i still have to ask passphrase by cmd – discCard Dec 09 '20 at 11:48
-
-
-
@discCard If you use `ssh target-host` the ssh_ask.bat should be started, if not (if the `SSH_ASKPASS` is wrong) you should see errors like `CreateProcessW failed error:2 ssh_askpass: posix_spawn: No such file or directory`. You could test that. If you get `Permission denied, please try again.` your user/passphrase is wrong – jeb Dec 09 '20 at 12:15
-
i wrote it in git bash and i got error: "ssh: Could not resolve hostname target-host: Name or service not known" and when i wrote it in cmd i got: " 'ssh is not recognized as an internal command' " – discCard Dec 09 '20 at 12:29