ssh.config 'Host' line allows Multiple space-separated entries, and wildcards. Neither works with ssh command.
I suggest splitting each Host line, and filtering out any entry with a wildcard.
I have done limited testing with the following minimal change to the parseHosts function, and it appears to work (I am not proficient in javaScript, so there is likely a better way to do it):
/**
*
* @param {String} sshConfig The ssh config file to parse
* @returns {Array} An array of hosts
*/
parseHosts(sshConfig) {
var ret = []
var allHostLines = sshConfig
.split('\n')
.join('{{NEWLINE}}')
.split('\r')
.join('{{NEWLINE}}')
.split('{{NEWLINE}}')
.map(item => item.trim())
.filter(item => item.indexOf('Host ') === 0)
.map(item => item = item.split('Host ')[1]);
allHostLines.forEach(hostLine => {
// need to replace multiple spaces with single speces to the split doesn't have null entries
hostLine.replace(/\s\s+/g, " ").split(" ").forEach(hostStr => {
if (!["*","?"].some(v => hostStr.includes(v))) {
ret.push(hostStr)
}
});
});
return ret;
}
ssh.config 'Host' line allows Multiple space-separated entries, and wildcards. Neither works with ssh command. I suggest splitting each Host line, and filtering out any entry with a wildcard. I have done limited testing with the following minimal change to the parseHosts function, and it appears to work (I am not proficient in javaScript, so there is likely a better way to do it):