Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Key will be added to server's tags and added to root user on next restart.
Key is expected in openssh format "(format) (key) (comment)".
The comment will be used as key name or generated
Lookup /root/.ssh/authorized_keys on your server for more information

USAGE:
scw instance ssh add-key [arg=value ...]

ARGS:
[server-id] Server to add your key to
[public-key] Public key you want to add to your server
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | fr-par-3 | nl-ams-1 | nl-ams-2 | pl-waw-1 | pl-waw-2)

FLAGS:
-h, --help help for add-key

GLOBAL FLAGS:
-c, --config string The path to the config file
-D, --debug Enable debug mode
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
-p, --profile string The config profile to use
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Path of the config will be $HOME/.ssh/scaleway.config

USAGE:
scw instance ssh install-config [arg=value ...]

ARGS:
[project-id] Project ID to use. If none is passed the default project ID will be used
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | fr-par-3 | nl-ams-1 | nl-ams-2 | pl-waw-1 | pl-waw-2)

FLAGS:
-h, --help help for install-config

GLOBAL FLAGS:
-c, --config string The path to the config file
-D, --debug Enable debug mode
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
-p, --profile string The config profile to use
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
List only keys added manually to a server using tags.
The key comment is used as key name or generated
Lookup /root/.ssh/authorized_keys on your server for more information

USAGE:
scw instance ssh list-keys <server-id ...> [arg=value ...]

ARGS:
server-id Server to add your key to
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | fr-par-3 | nl-ams-1 | nl-ams-2 | pl-waw-1 | pl-waw-2)

FLAGS:
-h, --help help for list-keys

GLOBAL FLAGS:
-c, --config string The path to the config file
-D, --debug Enable debug mode
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
-p, --profile string The config profile to use
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Key will be remove from server's tags and removed from root user on next restart.
Keys are identified by their comment as in openssh format.
Lookup /root/.ssh/authorized_keys on your server for more information

USAGE:
scw instance ssh remove-key [arg=value ...]

ARGS:
server-id Server to add your key to
[name] Name of the key you want to remove, has to be the key comment or the index
[public-key] Public key you want to remove
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | fr-par-3 | nl-ams-1 | nl-ams-2 | pl-waw-1 | pl-waw-2)

FLAGS:
-h, --help help for remove-key

GLOBAL FLAGS:
-c, --config string The path to the config file
-D, --debug Enable debug mode
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
-p, --profile string The config profile to use
28 changes: 28 additions & 0 deletions cmd/scw/testdata/test-all-usage-instance-ssh-usage.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Command utilities around server SSH
- Manage keys per server
- Generate ssh config

USAGE:
scw instance ssh <command>

UTILITY COMMANDS:
add-key Add a public key to a server
list-keys List manually added public keys
remove-key Remove a manually added public key from a server

WORKFLOW COMMANDS:
install-config Install a ssh config with all your servers as host
It generate hosts for instance servers, baremetal, apple-silicon and bastions

FLAGS:
-h, --help help for ssh

GLOBAL FLAGS:
-c, --config string The path to the config file
-D, --debug Enable debug mode
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
-p, --profile string The config profile to use

Use "scw instance ssh [command] --help" for more information about a command.
1 change: 1 addition & 0 deletions cmd/scw/testdata/test-all-usage-instance-usage.golden
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ AVAILABLE COMMANDS:
server Instance management commands
server-type Instance type management commands
snapshot Snapshot management commands
ssh SSH Utilities
user-data User data management commands
volume Volume management commands
volume-type Volume type management commands
Expand Down
105 changes: 105 additions & 0 deletions docs/commands/instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ Instance API.
- [List snapshots](#list-snapshots)
- [Update a snapshot](#update-a-snapshot)
- [Wait for snapshot to reach a stable state](#wait-for-snapshot-to-reach-a-stable-state)
- [SSH Utilities](#ssh-utilities)
- [Add a public key to a server](#add-a-public-key-to-a-server)
- [Install a ssh config with all your servers as host
It generate hosts for instance servers, baremetal, apple-silicon and bastions](#install-a-ssh-config-with-all-your-servers-as-host
it-generate-hosts-for-instance-servers,-baremetal,-apple-silicon-and-bastions)
- [List manually added public keys](#list-manually-added-public-keys)
- [Remove a manually added public key from a server](#remove-a-manually-added-public-key-from-a-server)
- [User data management commands](#user-data-management-commands)
- [Delete user data](#delete-user-data)
- [Get user data](#get-user-data)
Expand Down Expand Up @@ -2588,6 +2595,104 @@ scw instance snapshot wait 11111111-1111-1111-1111-111111111111



## SSH Utilities

Command utilities around server SSH
- Manage keys per server
- Generate ssh config


### Add a public key to a server

Key will be added to server's tags and added to root user on next restart.
Key is expected in openssh format "(format) (key) (comment)".
The comment will be used as key name or generated
Lookup /root/.ssh/authorized_keys on your server for more information

**Usage:**

```
scw instance ssh add-key [arg=value ...]
```


**Args:**

| Name | | Description |
|------|---|-------------|
| server-id | | Server to add your key to |
| public-key | | Public key you want to add to your server |
| zone | Default: `fr-par-1`<br />One of: `fr-par-1`, `fr-par-2`, `fr-par-3`, `nl-ams-1`, `nl-ams-2`, `pl-waw-1`, `pl-waw-2` | Zone to target. If none is passed will use default zone from the config |



### Install a ssh config with all your servers as host
It generate hosts for instance servers, baremetal, apple-silicon and bastions

Path of the config will be $HOME/.ssh/scaleway.config

**Usage:**

```
scw instance ssh install-config [arg=value ...]
```


**Args:**

| Name | | Description |
|------|---|-------------|
| project-id | | Project ID to use. If none is passed the default project ID will be used |
| zone | Default: `fr-par-1`<br />One of: `fr-par-1`, `fr-par-2`, `fr-par-3`, `nl-ams-1`, `nl-ams-2`, `pl-waw-1`, `pl-waw-2` | Zone to target. If none is passed will use default zone from the config |



### List manually added public keys

List only keys added manually to a server using tags.
The key comment is used as key name or generated
Lookup /root/.ssh/authorized_keys on your server for more information

**Usage:**

```
scw instance ssh list-keys <server-id ...> [arg=value ...]
```


**Args:**

| Name | | Description |
|------|---|-------------|
| server-id | Required | Server to add your key to |
| zone | Default: `fr-par-1`<br />One of: `fr-par-1`, `fr-par-2`, `fr-par-3`, `nl-ams-1`, `nl-ams-2`, `pl-waw-1`, `pl-waw-2` | Zone to target. If none is passed will use default zone from the config |



### Remove a manually added public key from a server

Key will be remove from server's tags and removed from root user on next restart.
Keys are identified by their comment as in openssh format.
Lookup /root/.ssh/authorized_keys on your server for more information

**Usage:**

```
scw instance ssh remove-key [arg=value ...]
```


**Args:**

| Name | | Description |
|------|---|-------------|
| server-id | Required | Server to add your key to |
| name | | Name of the key you want to remove, has to be the key comment or the index |
| public-key | | Public key you want to remove |
| zone | Default: `fr-par-1`<br />One of: `fr-par-1`, `fr-par-2`, `fr-par-3`, `nl-ams-1`, `nl-ams-2`, `pl-waw-1`, `pl-waw-2` | Zone to target. If none is passed will use default zone from the config |



## User data management commands

User data is a key value store API you can use to provide data to your Instance without authentication.
Expand Down
12 changes: 12 additions & 0 deletions internal/namespaces/instance/v1/custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,18 @@ func GetCommands() *core.Commands {

cmds.MustFind("instance", "private-nic", "get").Override(privateNicGetBuilder)

// SSH Utilities

human.RegisterMarshalerFunc([]*SSHKeyFormat(nil), marshalSSHKeys)

cmds.Merge(core.NewCommands(
instanceSSH(),
sshAddKeyCommand(),
sshConfigInstallCommand(),
sshListKeysCommand(),
sshRemoveKeyCommand(),
))

return cmds
}

Expand Down
Loading