Skip to content

Commit

Permalink
Sudo access
Browse files Browse the repository at this point in the history
  • Loading branch information
gergas3 committed Feb 28, 2024
1 parent 2cc68a4 commit 4f70cdd
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/commands/ssh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export type SshCommandArgs = {
command?: string;
L?: string; // port forwarding option
arguments: string[];
sudo?: boolean;
};

// Matches strings with the pattern "digits:digits" (e.g. 1234:5678)
Expand All @@ -52,6 +53,10 @@ export const sshCommand = (yargs: yargs.Argv) =>
type: "string",
demandOption: true,
})
.option("sudo", {
type: "boolean",
describe: "Elevated access to the instance",
})
.positional("command", {
type: "string",
describe: "Pass command to the shell",
Expand Down Expand Up @@ -146,10 +151,12 @@ const ssh = async (args: yargs.ArgumentsCamelCase<SshCommandArgs>) => {
// Prefix is required because the backend uses it to determine that this is an AWS request
const authn = await authenticate();
await validateSshInstall(authn);
const requestArgs = ["ssh", args.destination, "--provider", "aws"];
if (args.sudo || args.command === "sudo") requestArgs.push("--sudo");
const response = await request(
{
...pick(args, "$0", "_"),
arguments: ["ssh", args.destination, "--provider", "aws"],
arguments: requestArgs,
wait: true,
},
authn,
Expand Down

0 comments on commit 4f70cdd

Please sign in to comment.