Force update known hosts every time

main
Aaron Marais 2023-03-30 22:45:12 +02:00
parent c433fca575
commit 2ff767fc30
3 changed files with 3 additions and 6 deletions

2
dist/index.js vendored

File diff suppressed because one or more lines are too long

View File

@ -18,10 +18,7 @@ const run = async () => {
// Add SSH key // Add SSH key
addSshKey(sshPrivateKey, deployKeyName); addSshKey(sshPrivateKey, deployKeyName);
const { path: privateKeyPath } = getPrivateKeyPath(deployKeyName); const { path: privateKeyPath } = getPrivateKeyPath(deployKeyName);
// Update known hosts if ssh command is present to avoid prompt updateKnownHosts(remoteHost, remotePort);
if (scriptBefore || scriptAfter) {
updateKnownHosts(remoteHost, remotePort);
}
// Check Script before // Check Script before
if (scriptBefore) { if (scriptBefore) {
await remoteCmdBefore(scriptBefore, privateKeyPath); await remoteCmdBefore(scriptBefore, privateKeyPath);

View File

@ -19,7 +19,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.replace(/\r\n/g, "\n")}\n`, isRequired: true, mode: '0400' }); writeToFile({ dir, filename, content: `${content.replace(/\r\n/g, '\n')}\n`, isRequired: true, mode: '0400' });
console.log('✅ [SSH] key added to `.ssh` dir ', dir, filename); console.log('✅ [SSH] key added to `.ssh` dir ', dir, filename);
}; };