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?)
Sorry, I couldn't find the answer to this question either. The best I could do was to [open an SSH tunnel](https://help.ubuntu.com/community/SSH/OpenSSH/PortForwarding), so that I could temporarily access the server's web GUI from my local computer:

```
ssh -L 8080:localhost:8384 your.host.name

```

Then you can access the remote web GUI from http://localhost:8080