Skip to content

Commit d773048

Browse files
committed
docs: document --api flag and api file for remote node access
add documentation for connecting to remote IPFS nodes: - --api flag for per-command override - $IPFS_PATH/api file for persistent configuration updated in both CLI reference and quick-start guide with cross-references between them.
1 parent c5f6329 commit d773048

File tree

5 files changed

+102
-33
lines changed

5 files changed

+102
-33
lines changed

docs/how-to/command-line-quick-start.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,54 @@ Next, take your node online and interact with the IPFS network:
202202

203203
By default, your gateway is not exposed to the world. It only works locally.
204204

205+
## Interact with a remote node
206+
207+
By default, CLI commands talk to the daemon running on your local machine. If your daemon runs on a different machine or inside a container, there are two ways to connect to it.
208+
209+
### Using the --api flag
210+
211+
Use the `--api` flag to specify the remote API address:
212+
213+
```bash
214+
ipfs --api /ip4/192.168.1.100/tcp/5001 id
215+
```
216+
217+
The address uses [multiaddr](../concepts/glossary.md#multiaddr) format. Some common examples:
218+
219+
- `/ip4/192.168.1.100/tcp/5001` - IPv4 address
220+
- `/ip6/::1/tcp/5001` - IPv6 address
221+
- `/dns/node.example.com/tcp/5001` - DNS name
222+
223+
### Using the `api` file
224+
225+
To avoid passing `--api` to every command, create an `api` file in your IPFS repository containing the multiaddr of the remote API:
226+
227+
```bash
228+
echo "/ip4/192.168.1.100/tcp/5001" > ~/.ipfs/api
229+
```
230+
231+
Now all commands will use the remote node:
232+
233+
```bash
234+
ipfs id
235+
```
236+
237+
:::tip
238+
Kubo creates `$IPFS_PATH/api` automatically when `ipfs daemon` starts. You can also create this file manually to connect to:
239+
240+
- A Kubo node running in Docker or another container
241+
- A remote server running `ipfs daemon`
242+
- An [IPFS Desktop](../install/ipfs-desktop.md) node (the `api` file is created automatically at `~/.ipfs/api`)
243+
244+
The `--api` flag takes precedence over the `api` file.
245+
:::
246+
247+
For TLS-secured remote APIs with authentication (`--api-auth`), see [Securing Kubo RPC API](kubo-rpc-tls-auth.md).
248+
249+
:::tip Read-only access
250+
If you only need to retrieve content without pinning or adding files, consider using the [HTTP Gateway](../reference/http/gateway.md) instead.
251+
:::
252+
205253
## Interact with the node using the web console
206254

207255
You can view the web console for your local node by navigating to `localhost:5001/webui`.

docs/install/command-line.md

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -319,38 +319,15 @@ For the current instructions on how to manually download, compile and build Kubo
319319

320320
## Determining which node to use with the command line
321321

322-
The command line can detect and use any node that's running, unless it's configured to use an external binary file. Here's which node to use for the local daemon or a remote client:
322+
The CLI automatically connects to a running IPFS daemon by reading the `$IPFS_PATH/api` file (usually `~/.ipfs/api`), which contains the [RPC API](../reference/kubo/rpc.md) address.
323323

324-
### Local daemon
325-
326-
The local daemon process is automatically started in the CLI with the command `ipfs daemon`. It creates an `$IPFS_PATH/api` file with an [RPC API](../reference/kubo/rpc.md#http-rpc-api-reference) address.
327-
328-
### Remote client
329-
330-
You can install the standalone IPFS CLI client independently and use it to talk to an IPFS Desktop (Kubo) node. Use the [RPC API](../reference/kubo/rpc.md#http-rpc-api-reference) to talk to the `ipfs` daemon.
331-
332-
When an IPFS command executes without parameters, the CLI client checks whether the `$IPFS_PATH/api` file exists and connects to the address listed there.
333-
334-
- If an `$IPFS_PATH` is in the default location (for example, `~/.ipfs` on Linux), then it works automatically and the IPFS CLI client talks to the locally running `ipfs` daemon without any extra configuration.
335-
336-
- If an `$IPFS_PATH` isn't in the default location, use the `--api <rpc-api-addr>` command-line argument. Alternatively, you can set the environment variable to `IPFS_PATH`. `IPFS_PATH` will point to a directory with the `$IPFS_PATH/api` file pointing at the Kubo RPC of the existing `ipfs` daemon instance.
337-
338-
::: tip
339-
340-
If you plan to expose the RPC API to the public internet with TLS encryption and HTTP authentication, check out the [TLS and HTTP Auth for Kubo with Caddy](../how-to/kubo-rpc-tls-auth.md) guide.
341-
342-
If you are just interested in retrieval, see implementation-agnostic [HTTP Gateway](../reference/http/gateway.md) instead.
324+
- **Local daemon**: Running `ipfs daemon` creates this file automatically.
325+
- **Remote node**: To connect to a daemon on another machine or in a container, see [Interact with a remote node](../how-to/command-line-quick-start.md#interact-with-a-remote-node).
343326

327+
:::tip
328+
For TLS-secured APIs, see [Secure Kubo RPC with TLS and HTTP Auth](../how-to/kubo-rpc-tls-auth.md). If you are just interested in retrieval, see implementation-agnostic [HTTP Gateway](../reference/http/gateway.md) instead.
344329
:::
345330

346-
#### Most common examples
347-
348-
If you are an IPFS Desktop user, you can install CLI tools and an `.ipfs/api` file is automatically picked up.
349-
350-
If you're not running IPFS Desktop, specify a custom port with `ipfs --api /ip4/127.0.0.1/tcp/<port> id` in the CLI.
351-
352-
You can use `mkdir -p ~/.ipfs && echo "/ip4/<ip>/tcp/<rpc-port>" > ~/.ipfs/api` to avoid passing `--api` every time.
353-
354331
## Next steps
355332

356333
Now that you've installed IPFS Kubo:

docs/install/run-ipfs-inside-docker.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ You can run Kubo IPFS inside Docker to simplify your deployment processes, as we
6262
docker exec ipfs_host ipfs add -r /export/<something>
6363
```
6464

65+
:::tip Using your local ipfs CLI
66+
If you have `ipfs` installed on the host and the RPC API port is exposed, you can run commands without `docker exec`. See [Interact with a remote node](../how-to/command-line-quick-start.md#interact-with-a-remote-node) for details.
67+
:::
68+
6569
1. Stop the running container:
6670

6771
```shell

docs/reference/kubo/cli.md

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: API documentation for the Kubo command-line executable.
55

66
# Kubo command-line
77

8-
::: tip Generated on 2025-11-27 03:54:28, from kubo 0.39.0
8+
::: tip Generated on 2025-12-02 22:04:13, from kubo 0.39.0
99
This document was autogenerated from CLI help text in [kubo 0.39.0](https://github.com/ipfs/kubo/releases/tag/v0.39.0)
1010
For issues and support, check out the [generate-cli-docs.sh](https://github.com/ipfs/ipfs-docs/blob/main/docs/reference/kubo/generate-cli-docs.sh) script on GitHub.
1111
:::
@@ -14,13 +14,13 @@ For issues and support, check out the [generate-cli-docs.sh](https://github.com/
1414

1515
IPFS can run in either _online_ or _offline_ mode. Online mode is when you have IPFS running separately as a daemon process. If you do not have an IPFS daemon running, you are in offline mode. Some commands, like `ipfs swarm peers`, are only supported when online.
1616

17-
The [command-line quickstart guide](/how-to/command-line-quick-start/#take-your-node-online) explains how to start the IPFS daemon and take your node online.
17+
The [command-line quickstart guide](../../how-to/command-line-quick-start.md#take-your-node-online) explains how to start the IPFS daemon and take your node online.
1818

1919

2020

2121
### Alignment with Kubo RPC API
2222

23-
Every command usable from the CLI is also available through the [RPC API v0](/reference/kubo/rpc). For example:
23+
Every command usable from the CLI is also available through the [RPC API v0](rpc.md). For example:
2424

2525
```sh
2626
> ipfs swarm peers
@@ -38,6 +38,26 @@ Every command usable from the CLI is also available through the [RPC API v0](/re
3838
}
3939
```
4040

41+
### Connecting to a Remote API
42+
43+
By default, CLI commands connect to the local daemon at `/ip4/127.0.0.1/tcp/5001`. There are two ways to connect to a different instance:
44+
45+
1. Use the `--api` flag:
46+
47+
```sh
48+
ipfs --api /ip4/192.168.1.100/tcp/5001 id
49+
```
50+
51+
2. Create an `api` file in your IPFS repository (`$IPFS_PATH/api`, usually `~/.ipfs/api`) containing the [multiaddr](../../concepts/glossary.md#multiaddr) of the API endpoint:
52+
53+
```sh
54+
echo /ip4/192.168.1.100/tcp/5001 > ~/.ipfs/api
55+
ipfs id
56+
```
57+
58+
Kubo creates this file automatically when `ipfs daemon` starts. Creating it manually lets you use a remote node without passing `--api` to every command.
59+
60+
For a step-by-step guide, see [Interact with a remote node](../../how-to/command-line-quick-start.md#interact-with-a-remote-node). For TLS-secured APIs with authentication (`--api-auth`), see [Securing Kubo RPC API](../../how-to/kubo-rpc-tls-auth.md).
4161

4262

4363
## ipfs

docs/reference/kubo/generate-cli-docs.sh

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ For issues and support, check out the [generate-cli-docs.sh](https://github.com/
2121
2222
IPFS can run in either _online_ or _offline_ mode. Online mode is when you have IPFS running separately as a daemon process. If you do not have an IPFS daemon running, you are in offline mode. Some commands, like \`ipfs swarm peers\`, are only supported when online.
2323
24-
The [command-line quickstart guide](/how-to/command-line-quick-start/#take-your-node-online) explains how to start the IPFS daemon and take your node online.
24+
The [command-line quickstart guide](../../how-to/command-line-quick-start.md#take-your-node-online) explains how to start the IPFS daemon and take your node online.
2525
2626
"
2727

2828
echo "
2929
### Alignment with Kubo RPC API
3030
31-
Every command usable from the CLI is also available through the [RPC API v0](/reference/kubo/rpc). For example:
31+
Every command usable from the CLI is also available through the [RPC API v0](rpc.md). For example:
3232
3333
\`\`\`sh
3434
> ipfs swarm peers
@@ -46,6 +46,26 @@ Every command usable from the CLI is also available through the [RPC API v0](/re
4646
}
4747
\`\`\`
4848
49+
### Connecting to a Remote API
50+
51+
By default, CLI commands connect to the local daemon at \`/ip4/127.0.0.1/tcp/5001\`. There are two ways to connect to a different instance:
52+
53+
1. Use the \`--api\` flag:
54+
55+
\`\`\`sh
56+
ipfs --api /ip4/192.168.1.100/tcp/5001 id
57+
\`\`\`
58+
59+
2. Create an \`api\` file in your IPFS repository (\`\$IPFS_PATH/api\`, usually \`~/.ipfs/api\`) containing the [multiaddr](../../concepts/glossary.md#multiaddr) of the API endpoint:
60+
61+
\`\`\`sh
62+
echo "/ip4/192.168.1.100/tcp/5001" > ~/.ipfs/api
63+
ipfs id
64+
\`\`\`
65+
66+
Kubo creates this file automatically when \`ipfs daemon\` starts. Creating it manually lets you use a remote node without passing \`--api\` to every command.
67+
68+
For a step-by-step guide, see [Interact with a remote node](../../how-to/command-line-quick-start.md#interact-with-a-remote-node). For TLS-secured APIs with authentication (\`--api-auth\`), see [Securing Kubo RPC API](../../how-to/kubo-rpc-tls-auth.md).
4969
"
5070
printf "\n"
5171
ipfs commands | while read line ; do

0 commit comments

Comments
 (0)