feat: ssh.ts
This commit is contained in:
@@ -112,17 +112,12 @@ function parseUsernameAndHost(usernameAndHost: string): UsernameAndHost {
|
|||||||
}
|
}
|
||||||
const usernameAndHostParts = usernameAndHost.split("@");
|
const usernameAndHostParts = usernameAndHost.split("@");
|
||||||
if (usernameAndHostParts.length == 1) {
|
if (usernameAndHostParts.length == 1) {
|
||||||
return {
|
return { host: usernameAndHostParts[0] };
|
||||||
host: usernameAndHostParts[0],
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
if (usernameAndHostParts.length > 2) {
|
if (usernameAndHostParts.length > 2) {
|
||||||
throw new Error(`Base username@host: ${usernameAndHost}`);
|
throw new Error(`Base username@host: ${usernameAndHost}`);
|
||||||
}
|
}
|
||||||
return {
|
return { username: usernameAndHostParts[0], host: usernameAndHostParts[1] };
|
||||||
username: usernameAndHostParts[0],
|
|
||||||
host: usernameAndHostParts[1],
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
@@ -134,22 +129,10 @@ async function main() {
|
|||||||
}
|
}
|
||||||
const args = process.argv.slice(2);
|
const args = process.argv.slice(2);
|
||||||
const options = {
|
const options = {
|
||||||
"forward-agent": {
|
"forward-agent": { type: "boolean", short: "f" },
|
||||||
type: "boolean",
|
"proxy": { type: "boolean", short: "p" },
|
||||||
short: "f",
|
"help": { type: "boolean", short: "h" },
|
||||||
},
|
"host": { type: "string", short: "H" },
|
||||||
"proxy": {
|
|
||||||
type: "boolean",
|
|
||||||
short: "p",
|
|
||||||
},
|
|
||||||
"help": {
|
|
||||||
type: "boolean",
|
|
||||||
short: "h",
|
|
||||||
},
|
|
||||||
"host": {
|
|
||||||
type: "string",
|
|
||||||
short: "H",
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const { values, positionals } = parseArgs({
|
const { values, positionals } = parseArgs({
|
||||||
@@ -201,9 +184,7 @@ async function main() {
|
|||||||
sshArgs.push("-o");
|
sshArgs.push("-o");
|
||||||
sshArgs.push('"ProxyCommand=nc -X 5 -x 127.0.0.1:1080 %h %p"');
|
sshArgs.push('"ProxyCommand=nc -X 5 -x 127.0.0.1:1080 %h %p"');
|
||||||
}
|
}
|
||||||
sshArgs.push(
|
sshArgs.push(`${sshUsername}@${sshProfile.host}`);
|
||||||
`${sshUsername}@${sshProfile.host}`,
|
|
||||||
);
|
|
||||||
|
|
||||||
console.log(`${GREEN}[OK ]${RESET} ${sshCommand} ${sshArgs.join(" ")}`);
|
console.log(`${GREEN}[OK ]${RESET} ${sshCommand} ${sshArgs.join(" ")}`);
|
||||||
spawn(sshCommand, sshArgs, {
|
spawn(sshCommand, sshArgs, {
|
||||||
|
|||||||
Reference in New Issue
Block a user