# Clients
## Installation
```bash
# Gentoo
$ sudo emerge -av net-p2p/syncathing
```
## Running Automatically
### OpenRC
Syncthing might not come with a user init script. If not, you can use this one which is a modified version of the system-wide init script:
```bash
#!/sbin/openrc-run
SYNCTHING_HOMEDIR="${SYNCTHING_HOMEDIR:-${XDG_STATE_HOME:-$HOME/.local/state}/syncthing}"
SYNCTHING_UMASK=${SYNCTHING_UMASK:-007}
SYNCTHING_IONICE=${SYNCTHING_IONICE:-0}
SYNCTHING_NICE=${SYNCTHING_NICE:-0}
SYNCTHING_GUI_ADDRESS=${SYNCTHING_GUI_ADDRESS:-http://127.0.0.1:8384}
description="Syncthing is an open, trustworthy and decentralized cloud storage system"
command="/usr/bin/syncthing"
command_args="--home=${SYNCTHING_HOMEDIR} --no-browser \
--gui-address=${SYNCTHING_GUI_ADDRESS} ${SYNCTHING_OPTS}"
pidfile="${XDG_RUNTIME_DIR:-/run/user/1000}/${RC_SVCNAME}.pid"
command_background="yes"
umask="${SYNCTHING_UMASK}"
start_stop_daemon_args="--ionice ${SYNCTHING_IONICE} \
--nicelevel ${SYNCTHING_NICE}"
start_pre() {
checkpath -d $SYNCTHING_HOMEDIR
}
```
Save the user init script to either `/etc/user/init.d/` or `~/.config/rc/init.d/`.
```
$ rc-update --user add syncathing default
$ rc-service --user syncathing start
```
### Systemd
```bash
$ sudo loginctl enable-linger <user>
$ systemctl --user enable syncathing
$ systemctl --user start syncathing
```
## Running A Remote Client
You can run a Syncthing client on a remote server just like a normal machine. With this, you can have an automatic off-site backup solution.
```bash
# My remote server uses Systemd.
# As root, enable lingering for your user.
$ ssh root@<remote server>
$ loginctl enable-linger <user>
$ exit
# As the user, enable the Syncathing service.
$ ssh <user>@<remote server>
$ systemctl --user enable syncathing
$ systemctl --user start syncathing
$ exit
# Create an SSH tunnel that binds your local machine's port 8385 to the remote server's port 8384 (or the one which Syncathing is running on). You can use any local port you'd like so long as it doesn't interfere with the Syncthing client running on your local machine.
$ ssh -L 8385:localhost:8384 <user>@<remote server>
```
After you establish the SSH tunnel, you can view the web interface of the remote Syncthing client using your web browser by going to `http://localhost:8385` (change the port number if needed). Once you have the remote Syncthing client configured, you can close the SSH tunnel.