Fake askpass

This commit is contained in:
Matthias Pigulla 2021-03-01 08:09:30 +00:00
parent 25b1b5d69f
commit c91aeeb123
5 changed files with 4 additions and 30 deletions

View file

@ -1,10 +0,0 @@
on: [push, pull_request]
jobs:
compile:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- run: |
cl test.c
test

BIN
askpass.exe Executable file

Binary file not shown.

12
dist/index.js vendored
View file

@ -179,8 +179,6 @@ try {
console.log(`Write file ${keyFile}`); console.log(`Write file ${keyFile}`);
fs.writeFileSync(keyFile, key.replace("\r\n", "\n").trim() + "\n", { mode: '600' }); fs.writeFileSync(keyFile, key.replace("\r\n", "\n").trim() + "\n", { mode: '600' });
fs.writeFileSync(`${homeSsh}/askpass`, `echo ${token}`, { mode: '700' });
// Set private key passphrase // Set private key passphrase
let output = ''; let output = '';
try { try {
@ -193,23 +191,17 @@ try {
} }
// Load key into agent // Load key into agent
console.log('Load key');
//let sshAdd = child_process.execSync(`echo "${token}" | ssh-add "${keyFile}"`, { stdio: 'inherit' });
var sshAdd; var sshAdd;
try { try {
let sshAdd = child_process.execSync(`ssh-add ${keyFile}`, { env: { 'SSH_ASKPASS': `${homeSsh}/askpass` } }); let sshAdd = child_process.execSync(`ssh-add ${keyFile}`, { env: { 'DISPLAY': 'fake', 'SSH_PASS': token, 'SSH_ASKPASS': 'askpass' } });
} catch (exception) { } catch (exception) {
console.log(sshAdd); console.log(sshAdd.toString());
console.log(exception); console.log(exception);
throw exception; throw exception;
} }
console.log(sshAdd); console.log(sshAdd);
// input: token + "\n", stdio: ['pipe', 'inherit', 'inherit'] });
//sshAdd.stdin.write(token + "\n");
//sshAdd.stdin.end();
output.toString().split(/\r?\n/).forEach(function(key) { output.toString().split(/\r?\n/).forEach(function(key) {
let parts = key.match(/^Key has comment '.*\bgithub\.com[:/]([_.a-z0-9-]+\/[_.a-z0-9-]+?)(?=\.git|\s|\')/); let parts = key.match(/^Key has comment '.*\bgithub\.com[:/]([_.a-z0-9-]+\/[_.a-z0-9-]+?)(?=\.git|\s|\')/);

View file

@ -62,8 +62,6 @@ try {
console.log(`Write file ${keyFile}`); console.log(`Write file ${keyFile}`);
fs.writeFileSync(keyFile, key.replace("\r\n", "\n").trim() + "\n", { mode: '600' }); fs.writeFileSync(keyFile, key.replace("\r\n", "\n").trim() + "\n", { mode: '600' });
fs.writeFileSync(`${homeSsh}/askpass`, `echo ${token}`, { mode: '700' });
// Set private key passphrase // Set private key passphrase
let output = ''; let output = '';
try { try {
@ -76,23 +74,17 @@ try {
} }
// Load key into agent // Load key into agent
console.log('Load key');
//let sshAdd = child_process.execSync(`echo "${token}" | ssh-add "${keyFile}"`, { stdio: 'inherit' });
var sshAdd; var sshAdd;
try { try {
let sshAdd = child_process.execSync(`ssh-add ${keyFile}`, { env: { 'SSH_ASKPASS': `${homeSsh}/askpass` } }); let sshAdd = child_process.execSync(`ssh-add ${keyFile}`, { env: { 'DISPLAY': 'fake', 'SSH_PASS': token, 'SSH_ASKPASS': 'askpass' } });
} catch (exception) { } catch (exception) {
console.log(sshAdd); console.log(sshAdd.toString());
console.log(exception); console.log(exception);
throw exception; throw exception;
} }
console.log(sshAdd); console.log(sshAdd);
// input: token + "\n", stdio: ['pipe', 'inherit', 'inherit'] });
//sshAdd.stdin.write(token + "\n");
//sshAdd.stdin.end();
output.toString().split(/\r?\n/).forEach(function(key) { output.toString().split(/\r?\n/).forEach(function(key) {
let parts = key.match(/^Key has comment '.*\bgithub\.com[:/]([_.a-z0-9-]+\/[_.a-z0-9-]+?)(?=\.git|\s|\')/); let parts = key.match(/^Key has comment '.*\bgithub\.com[:/]([_.a-z0-9-]+\/[_.a-z0-9-]+?)(?=\.git|\s|\')/);