Last active
October 27, 2015 13:37
-
-
Save marcsolanadal/6ee4bd4983927aab4477 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shell.exec("ssh-keyscan" | |
+ " -p " + parsedUrl.port | |
+ " -t rsa " | |
+ parsedUrl.hostname, function(code, output) { | |
var commentedKey = output.split('\n'); | |
var key = commentedKey[1].split(' '); | |
publicKey = key[1] + ' ' + key[2]; | |
hostString = '[' + parsedUrl.hostname + ']:' + parsedUrl.port | |
+ ',[' + remoteIP + ']:' + parsedUrl.port | |
+ ' ' + publicKey + '\n'; | |
knownHosts = (knownHosts == null) ? [''] : knownHosts.split('\n'); | |
var inFile = false; | |
for (var i = 0; i < knownHosts.length; i++) { | |
if (hostString == knownHosts[i]) inFile = true; // <<<<<<<<<<<<<<<<<<<< | |
} | |
if(inFile == false) { | |
hostString.toEnd(knownHostPath); | |
reply('New key added into the known_hosts'); | |
} | |
else { | |
reply('The key is already in known_hosts'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment