# Command line

The tunnel engine is in `CrushTunnel.jar`, which every CrushMFT server has in its `WebInterface` folder. With Java you can start a tunnel on any machine, without the app: on Linux, on a server, or from your own program.

## Start one tunnel

One line:

```
java -cp CrushTunnel.jar com.crushftp.tunnel2.Tunnel2 protocol=https host=www.crushftp.com port=443 username=demo password=demo
```

The tunnel connects to the server over HTTPS and opens its local port on this machine. Programs on this machine (or others that can reach it) connect to that port and come out on the CrushMFT server's side. Everything between this machine and the server is encrypted.

Stop it with Ctrl-C.

## From the CrushClient prompt

[CrushClient](../CrushClient/Command-Line.md)'s prompt can start and stop tunnels:

```
java -jar CrushTunnel.jar
tunnel https://demo:demo@www.crushftp.com/
tunnel list
tunnel log
tunnel stop 1
```

| Command | Does |
|---|---|
| `tunnel <url>` | starts a tunnel. Without a login in the URL you are asked for it. |
| `tunnel list` | lists the tunnels, running and stopped, with their ids (1, 2, …) |
| `tunnel stop <id>` | stops one. A stopped tunnel cannot be started again; start a new one. |
| `tunnel log` | prints the tunnel's recent messages |

After `tunnel …`, `connect http://127.0.0.1:55555/` goes through it.

## In your own Java code

Put `CrushTunnel.jar` on the class path:

```
com.crushftp.tunnel2.Tunnel2 t = new com.crushftp.tunnel2.Tunnel2("https://www.crushftp.com:443/", "demo", "demo", false);
t.startThreads();
// The tunnel is open. Connections to its local port on 127.0.0.1 go securely through it to the CrushMFT server.

// later
t.stopThisTunnel();
```

## As a service

To have a tunnel up whenever the machine runs: [Always on](Always-On.md).
