Skip to content
4 changes: 2 additions & 2 deletions src/lib/nodes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ $ sf nodes set my-node-name --max-price 12.50
$ sf nodes extend my-node-name --duration 3600 --max-price 12.50

\x1b[2m# SSH into a node's current VM\x1b[0m
$ sf nodes ssh my-node-name
$ sf nodes ssh root@my-node-name

\x1b[2m# View logs from a node's current VM\x1b[0m
$ sf nodes logs my-node-name

\x1b[2m# SSH into a specific VM\x1b[0m
$ sf nodes ssh user@vm_xxxxxxxxxxxxxxxxxxxxx
$ sf nodes ssh root@vm_xxxxxxxxxxxxxxxxxxxxx

\x1b[2m# View logs from a specific VM\x1b[0m
$ sf nodes logs -i vm_xxxxxxxxxxxxxxxxxxxxx
Expand Down
19 changes: 11 additions & 8 deletions src/lib/nodes/ssh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ import { getApiUrl } from "../../helpers/urls.ts";
import { getAuthToken } from "../../helpers/config.ts";

const ssh = new Command("ssh")
.description("SSH into a VM on a node")
.description(`SSH into a VM on a node.

Runs \`ssh\` with host keys from the API, forgoing the need to manually accept keys on first connect.
Keys are fetched asynchronously from the VM's SSH server and may take a moment to populate.

Standard \`ssh\` behavior applies (e.g. defaults to your current username).`)
.showHelpAfterError()
.option("-q, --quiet", "Quiet mode", false)
.option(
Expand All @@ -27,25 +32,23 @@ const ssh = new Command("ssh")
.addOption(jsonOption)
.argument(
"<destination>",
"USERNAME@HOST The (optional) username, and node name/ID or VM ID to SSH into",
"Node name, Node ID, or VM ID to SSH into.\nFollows \`ssh\` behavior (i.e. root@node or jenson@node).",
)
.usage("[options] [user@]<destination>")
.allowExcessArguments(false)
.addHelpText(
"after",
`
Examples:

\x1b[2m# SSH into a node's current VM\x1b[0m
$ sf nodes ssh my-node
$ sf nodes ssh root@my-node

\x1b[2m# SSH with a specific username\x1b[0m
$ sf nodes ssh jenson@my-node

\x1b[2m# SSH directly to a VM ID\x1b[0m
$ sf nodes ssh vm_xxxxxxxxxxxxxxxxxxxxx

\x1b[2m# SSH with username to a VM ID\x1b[0m
$ sf nodes ssh huang@vm_xxxxxxxxxxxxxxxxxxxxx
$ sf nodes ssh root@vm_xxxxxxxxxxxxxxxxxxxxx
`,
)
.action(async (destination, options) => {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/vm/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ You can use ${
console.log(table.toString());
console.log(`\n${gray("Use VM IDs to access and replace VMs.")}\n`);
console.log(gray("Examples:"));
console.log(` sf vm ssh ${cyan(`USERNAME@${exampleId}`)}`);
console.log(` sf vm ssh ${cyan(`root@${exampleId}`)}`);
console.log(` sf vm logs -i ${cyan(exampleId)} -f`);
console.log(` sf vm replace -i ${cyan(exampleId)}`);
});
Expand Down
2 changes: 1 addition & 1 deletion src/lib/vm/ssh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function registerSsh(program: Command) {
)
.argument(
"<destination>",
"USERNAME@VM_ID The (optional) username, and VM id to SSH into.",
"[user@]vm_id - The (optional) username, and VM id to SSH into.",
)
.allowExcessArguments(false)
.action(async (destination, options) => {
Expand Down