Use custom port for host scan

main
Sebastian Blesgen 2023-02-10 18:55:53 +01:00
parent 164a3e861e
commit a1e01b2fad
4 changed files with 7 additions and 1980 deletions

2
dist/index.js vendored

File diff suppressed because one or more lines are too long

1979
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -23,11 +23,11 @@ const addSshKey = (content, deployKeyName) => {
console.log('✅ [SSH] key added to `.ssh` dir ', dir, filename); console.log('✅ [SSH] key added to `.ssh` dir ', dir, filename);
}; };
const updateKnownHosts = (host) => { const updateKnownHosts = (host, remotePort) => {
const { knownHostsPath } = getPrivateKeyPath(); const { knownHostsPath } = getPrivateKeyPath();
console.log('[SSH] Adding host to `known_hosts` ....', host, knownHostsPath); console.log('[SSH] Adding host to `known_hosts` ....', host, knownHostsPath);
try { try {
execSync(`ssh-keyscan -H ${host} >> ${knownHostsPath}`, { execSync(`ssh-keyscan -p ${(remotePort || 22)} -H ${host} >> ${knownHostsPath}`, {
stdio: 'inherit' stdio: 'inherit'
}); });
} catch (error) { } catch (error) {