Normalize line endings in SSH key for the underlying OS

This commit is contained in:
Måns Andersson
2023-07-26 11:49:29 +02:00
parent 3884c8554f
commit 3405be3b42
4 changed files with 17 additions and 4 deletions

2
dist/index.js vendored

File diff suppressed because one or more lines are too long

15
package-lock.json generated
View File

@@ -1,14 +1,15 @@
{
"name": "@draganfilipovic/ssh-deploy",
"version": "4.1.7",
"version": "4.1.8",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@draganfilipovic/ssh-deploy",
"version": "4.1.7",
"version": "4.1.8",
"license": "MIT",
"dependencies": {
"os": "^0.1.2",
"rsyncwrapper": "^3.0.1"
},
"devDependencies": {
@@ -1483,6 +1484,11 @@
"node": ">= 0.8.0"
}
},
"node_modules/os": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/os/-/os-0.1.2.tgz",
"integrity": "sha512-ZoXJkvAnljwvc56MbvhtKVWmSkzV712k42Is2mA0+0KTSRakq5XXuXpjZjgAt9ctzl51ojhQWakQQpmOvXWfjQ=="
},
"node_modules/p-limit": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz",
@@ -3061,6 +3067,11 @@
"word-wrap": "^1.2.3"
}
},
"os": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/os/-/os-0.1.2.tgz",
"integrity": "sha512-ZoXJkvAnljwvc56MbvhtKVWmSkzV712k42Is2mA0+0KTSRakq5XXuXpjZjgAt9ctzl51ojhQWakQQpmOvXWfjQ=="
},
"p-limit": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz",

View File

@@ -30,6 +30,7 @@
},
"homepage": "https://github.com/easingthemes/ssh-deploy#readme",
"dependencies": {
"os": "^0.1.2",
"rsyncwrapper": "^3.0.1"
},
"devDependencies": {

View File

@@ -1,6 +1,7 @@
const { join } = require('path');
const { execSync } = require('child_process');
const { writeToFile } = require('./helpers');
const { EOL } = require('os');
const KNOWN_HOSTS = 'known_hosts';
const getPrivateKeyPath = (filename = '') => {
@@ -19,7 +20,7 @@ const addSshKey = (content, deployKeyName) => {
const { dir, filename } = getPrivateKeyPath(deployKeyName);
writeToFile({ dir, filename: KNOWN_HOSTS, content: '' });
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);
};