Laravel Forge JavaScript SDK

SSH Keys

SSH Keys

Create a SSH key

Method

forge.ssh.create(server_id, payload)

Usage

1const forge = new Forge('API_TOKEN');
2
3const key = await forge.ssh.create(server_id, payload);

Payload

1{
2 name: 'test-key',
3 key: 'KEY_CONTENT',
4 username: 'forge'
5}

Payload Parameters

KeyDescription
nameThe name of the ssh key.
keyThe content of the key.
usernameThe username of the user you want to add the key to. If you are not using User Isolation, this will be forge.

Example Response

1{
2 "key": {
3 "id": 9,
4 "name": "test-key",
5 "username": "forge",
6 "status": "installing",
7 "created_at": "2016-12-16 16:31:16"
8 }
9}

List all SSH keys

Method

forge.ssh.list(server_id)

Usage

1const forge = new Forge('API_TOKEN');
2
3const keys = await forge.ssh.list(server_id);

Example Response

1{
2 "keys": [
3 {
4 "id": 9,
5 "name": "test-key",
6 "username": "forge",
7 "status": "installing",
8 "created_at": "2016-12-16 16:31:16"
9 }
10 ]
11}

Get a SSH key

Method

forge.ssh.get(server_id, key_id)

Usage

1const forge = new Forge('API_TOKEN');
2
3const key = await forge.ssh.get(server_id, key_id);

Example Response

1{
2 "key": {
3 "id": 9,
4 "name": "test-key",
5 "username": "forge",
6 "status": "installing",
7 "created_at": "2016-12-16 16:31:16"
8 }
9}

Delete a SSH key

Method

forge.ssh.delete(server_id, key_id)

Usage

1const forge = new Forge('API_TOKEN');
2
3await forge.ssh.delete(server_id, key_id);

Edit this page on GitHub