Merge pull request #156 from mansandersson/fix-key-line-endings

Normalize line endings in SSH key for the underlying OS
This commit is contained in:
Dragan Filipović 2023-09-30 17:12:46 +02:00 committed by GitHub
commit 448aa45aa1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

2
dist/index.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,6 @@
const { join } = require('path'); const { join } = require('path');
const { execSync } = require('child_process'); const { execSync } = require('child_process');
const { EOL } = require('os');
const { writeToFile } = require('./helpers'); const { writeToFile } = require('./helpers');
const KNOWN_HOSTS = 'known_hosts'; const KNOWN_HOSTS = 'known_hosts';
@ -19,7 +20,7 @@ const addSshKey = (content, deployKeyName) => {
const { dir, filename } = getPrivateKeyPath(deployKeyName); const { dir, filename } = getPrivateKeyPath(deployKeyName);
writeToFile({ dir, filename: KNOWN_HOSTS, content: '' }); writeToFile({ dir, filename: KNOWN_HOSTS, content: '' });
console.log('✅ [SSH] known_hosts file ensured', dir); console.log('✅ [SSH] known_hosts file ensured', dir);
writeToFile({ dir, filename, content: `${content}\r\n`, isRequired: true, mode: '0400' }); writeToFile({ dir, filename, content: `${content}${EOL}`, isRequired: true, mode: '0400' });
console.log('✅ [SSH] key added to `.ssh` dir ', dir, filename); console.log('✅ [SSH] key added to `.ssh` dir ', dir, filename);
}; };