mirror of
https://github.com/webfactory/ssh-agent.git
synced 2024-11-27 03:13:17 +00:00
Fake askpass
This commit is contained in:
parent
25b1b5d69f
commit
c91aeeb123
5 changed files with 4 additions and 30 deletions
10
.github/workflows/compile.yml
vendored
10
.github/workflows/compile.yml
vendored
|
@ -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
BIN
askpass.exe
Executable file
Binary file not shown.
12
dist/index.js
vendored
12
dist/index.js
vendored
|
@ -179,8 +179,6 @@ try {
|
|||
console.log(`Write file ${keyFile}`);
|
||||
fs.writeFileSync(keyFile, key.replace("\r\n", "\n").trim() + "\n", { mode: '600' });
|
||||
|
||||
fs.writeFileSync(`${homeSsh}/askpass`, `echo ${token}`, { mode: '700' });
|
||||
|
||||
// Set private key passphrase
|
||||
let output = '';
|
||||
try {
|
||||
|
@ -193,23 +191,17 @@ try {
|
|||
}
|
||||
|
||||
// Load key into agent
|
||||
console.log('Load key');
|
||||
//let sshAdd = child_process.execSync(`echo "${token}" | ssh-add "${keyFile}"`, { stdio: 'inherit' });
|
||||
var sshAdd;
|
||||
|
||||
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) {
|
||||
console.log(sshAdd);
|
||||
console.log(sshAdd.toString());
|
||||
console.log(exception);
|
||||
throw exception;
|
||||
}
|
||||
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) {
|
||||
let parts = key.match(/^Key has comment '.*\bgithub\.com[:/]([_.a-z0-9-]+\/[_.a-z0-9-]+?)(?=\.git|\s|\')/);
|
||||
|
||||
|
|
12
index.js
12
index.js
|
@ -62,8 +62,6 @@ try {
|
|||
console.log(`Write file ${keyFile}`);
|
||||
fs.writeFileSync(keyFile, key.replace("\r\n", "\n").trim() + "\n", { mode: '600' });
|
||||
|
||||
fs.writeFileSync(`${homeSsh}/askpass`, `echo ${token}`, { mode: '700' });
|
||||
|
||||
// Set private key passphrase
|
||||
let output = '';
|
||||
try {
|
||||
|
@ -76,23 +74,17 @@ try {
|
|||
}
|
||||
|
||||
// Load key into agent
|
||||
console.log('Load key');
|
||||
//let sshAdd = child_process.execSync(`echo "${token}" | ssh-add "${keyFile}"`, { stdio: 'inherit' });
|
||||
var sshAdd;
|
||||
|
||||
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) {
|
||||
console.log(sshAdd);
|
||||
console.log(sshAdd.toString());
|
||||
console.log(exception);
|
||||
throw exception;
|
||||
}
|
||||
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) {
|
||||
let parts = key.match(/^Key has comment '.*\bgithub\.com[:/]([_.a-z0-9-]+\/[_.a-z0-9-]+?)(?=\.git|\s|\')/);
|
||||
|
||||
|
|
Loading…
Reference in a new issue