mirror of
https://github.com/webfactory/ssh-agent.git
synced 2024-11-24 01:58:01 +00:00
add option use-base64 for encoded key
This commit is contained in:
parent
d4b9b8ff72
commit
4f7ffe435c
2 changed files with 14 additions and 2 deletions
8
dist/index.js
vendored
8
dist/index.js
vendored
|
@ -342,6 +342,7 @@ const { homePath, sshAgentCmdDefault, sshAddCmdDefault, gitCmdDefault } = __webp
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const privateKey = core.getInput('ssh-private-key');
|
const privateKey = core.getInput('ssh-private-key');
|
||||||
|
const useBase64 = core.getInput('use-base64');
|
||||||
const logPublicKey = core.getBooleanInput('log-public-key', {default: true});
|
const logPublicKey = core.getBooleanInput('log-public-key', {default: true});
|
||||||
|
|
||||||
const sshAgentCmdInput = core.getInput('ssh-agent-cmd');
|
const sshAgentCmdInput = core.getInput('ssh-agent-cmd');
|
||||||
|
@ -379,7 +380,12 @@ try {
|
||||||
|
|
||||||
console.log("Adding private key(s) to agent");
|
console.log("Adding private key(s) to agent");
|
||||||
|
|
||||||
privateKey.split(/(?=-----BEGIN)/).forEach(function(key) {
|
let decodedPrivateKey = privateKey;
|
||||||
|
// base64 decode privateKey
|
||||||
|
if (useBase64 === 'true') {
|
||||||
|
decodedPrivateKey = Buffer.from(privateKey, 'base64').toString('utf8');
|
||||||
|
}
|
||||||
|
decodedPrivateKey.split(/(?=-----BEGIN)/).forEach(function(key) {
|
||||||
child_process.execFileSync(sshAddCmd, ['-'], { input: key.trim() + "\n" });
|
child_process.execFileSync(sshAddCmd, ['-'], { input: key.trim() + "\n" });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
8
index.js
8
index.js
|
@ -6,6 +6,7 @@ const { homePath, sshAgentCmdDefault, sshAddCmdDefault, gitCmdDefault } = requir
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const privateKey = core.getInput('ssh-private-key');
|
const privateKey = core.getInput('ssh-private-key');
|
||||||
|
const useBase64 = core.getInput('use-base64');
|
||||||
const logPublicKey = core.getBooleanInput('log-public-key', {default: true});
|
const logPublicKey = core.getBooleanInput('log-public-key', {default: true});
|
||||||
|
|
||||||
const sshAgentCmdInput = core.getInput('ssh-agent-cmd');
|
const sshAgentCmdInput = core.getInput('ssh-agent-cmd');
|
||||||
|
@ -43,7 +44,12 @@ try {
|
||||||
|
|
||||||
console.log("Adding private key(s) to agent");
|
console.log("Adding private key(s) to agent");
|
||||||
|
|
||||||
privateKey.split(/(?=-----BEGIN)/).forEach(function(key) {
|
let decodedPrivateKey = privateKey;
|
||||||
|
// base64 decode privateKey
|
||||||
|
if (useBase64 === 'true') {
|
||||||
|
decodedPrivateKey = Buffer.from(privateKey, 'base64').toString('utf8');
|
||||||
|
}
|
||||||
|
decodedPrivateKey.split(/(?=-----BEGIN)/).forEach(function(key) {
|
||||||
child_process.execFileSync(sshAddCmd, ['-'], { input: key.trim() + "\n" });
|
child_process.execFileSync(sshAddCmd, ['-'], { input: key.trim() + "\n" });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue