mirror of
https://github.com/webfactory/ssh-agent.git
synced 2025-04-24 23:12:13 +00:00
#68 Option 2: Use lower case key
This commit is contained in:
parent
4b6f4eb000
commit
18547f3cc4
1 changed files with 4 additions and 3 deletions
7
index.js
7
index.js
|
@ -50,16 +50,17 @@ try {
|
|||
console.log('Configuring deployment key(s)');
|
||||
|
||||
child_process.execFileSync(sshAdd, ['-L']).toString().split(/\r?\n/).forEach(function(key) {
|
||||
const parts = key.match(/\bgithub\.com[:/]([_.a-z0-9-]+\/[_.a-z0-9-]+)/);
|
||||
var lowerCaseKey = key.ToLowerCase();
|
||||
const parts = lowerCaseKey.match(/\bgithub\.com[:/]([_.a-z0-9-]+\/[_.a-z0-9-]+)/);
|
||||
|
||||
if (!parts) {
|
||||
return;
|
||||
}
|
||||
|
||||
const sha256 = crypto.createHash('sha256').update(key).digest('hex');
|
||||
const sha256 = crypto.createHash('sha256').update(lowerCaseKey).digest('hex');
|
||||
const ownerAndRepo = parts[1].replace(/\.git$/, '');
|
||||
|
||||
fs.writeFileSync(`${homeSsh}/key-${sha256}`, key + "\n", { mode: '600' });
|
||||
fs.writeFileSync(`${homeSsh}/key-${sha256}`, lowerCaseKey + "\n", { mode: '600' });
|
||||
|
||||
child_process.execSync(`git config --global --replace-all url."git@key-${sha256}.github.com:${ownerAndRepo}".insteadOf "https://github.com/${ownerAndRepo}"`);
|
||||
child_process.execSync(`git config --global --add url."git@key-${sha256}.github.com:${ownerAndRepo}".insteadOf "git@github.com:${ownerAndRepo}"`);
|
||||
|
|
Loading…
Add table
Reference in a new issue