kopia lustrzana https://github.com/c9/core
use proxy command
rodzic
48502343da
commit
c1af528b87
|
@ -12,6 +12,21 @@ var fs = require("fs");
|
|||
var tmp = require("tmp");
|
||||
var debug = require("debug")("ssh");
|
||||
|
||||
function quote(str) {
|
||||
return "'" + str.replace(/'/g, "'\\''") + "'";
|
||||
}
|
||||
|
||||
function addProxyCommand(args, proxy) {
|
||||
var m = /^(.+)(?::(\d+))?$/.exec(proxy);
|
||||
if (!m)
|
||||
return;
|
||||
var proxyHost = m[1];
|
||||
var proxyPort = parseInt(m[2], 10) || 22;
|
||||
args.push(
|
||||
"-o", "ProxyCommand=ssh -W %h:%p -p " + proxyPort + " " + quote(proxyHost)
|
||||
);
|
||||
}
|
||||
|
||||
exports.buildArgs = function(prvkeyFile, host, proxy) {
|
||||
var args = [
|
||||
"-o", "PasswordAuthentication=no",
|
||||
|
@ -27,21 +42,15 @@ exports.buildArgs = function(prvkeyFile, host, proxy) {
|
|||
"-o", "ConnectTimeout=10" // default timeout is 2 minutes, which is quite long
|
||||
];
|
||||
|
||||
if (proxy)
|
||||
addProxyCommand(args, proxy);
|
||||
|
||||
if (host) {
|
||||
host = host.split(":");
|
||||
args.push("-p", host[1] || 22);
|
||||
args.push(host[0]);
|
||||
}
|
||||
|
||||
if (proxy) {
|
||||
args.push(
|
||||
"ssh",
|
||||
"-o", "UserKnownHostsFile=/dev/null",
|
||||
"-o", "StrictHostKeyChecking=no",
|
||||
"-o", "IdentitiesOnly=yes",
|
||||
proxy
|
||||
);
|
||||
}
|
||||
|
||||
return args;
|
||||
};
|
||||
|
|
Ładowanie…
Reference in New Issue