Question: How can I configure Syncthing from command line to share a folder with another computer with a specific ID?

Hello,

Having looked in a bit into the matter, using Syncthing from command line on Linux seems to be possible but requires either editing the configuration file or using the REST API.

How can I configure Syncthing to share a specific folder on the server computer with another computer that has a specific ID?

Vesa

Platform: Linux

Restrictions: Looking for scriptable solution without using the GUI

Answer: 
I think with the following commands you should be able to write a script for that.

We have a local machine and a Server. I assume you have ssh access to the Server.

Get your ID and the Server's ID with

```
syncthing cli show system | jq .myID

```

On the Server

```
syncthing cli config devices add --device-id $LocalID

```

On the local machine

```
syncthing cli config devices add --device-id $ServerID

```

Get the folder IDs

```
syncthing cli config folders list

```

Check if it is the intended path (e.g. in a loop)

```
syncthing cli config folders $folderID dump-json | jq .path

```

or dump the whole config (`syncthing cli config dump-json`) and select the folder from there

```
syncthing cli config dump-json | jq '.folders[] | select(.path == "/home/you/your/path") | .id'

```

now share this folder with the server

```
syncthing cli config folders $folderID devices add --device-id $ServerID

```

The only thing left is, that you have to accept the shared folder on the Server. (As I didn't find the right command for that yet. Maybe you will?)
I found a solution to your problem. I documented how to do it in this gist: <https://gist.github.com/Jonny-exe/9bad76c3adc6e916434005755ea70389>

If you don't want to read the whole gist, here are the main commands:

`syncthing cli config devices add --device-id $DEVICE_ID_B`

`syncthing cli config folders $FOLDER_ID devices add $DEVICE_ID_B`

`syncthing cli config devices $DEVICE_ID_A auto-accept-folders set true`

These commands are explained in the gist