ipfs-swarm-cli
v1.0.8
Published
A comprehensive CLI tool for managing private IPFS swarms. This tool simplifies the process of setting up and maintaining IPFS nodes in a private swarm configuration.
Downloads
14
Readme
IPFS Swarm CLI
A comprehensive CLI tool for managing private IPFS swarms. This tool simplifies the process of setting up and maintaining IPFS nodes in a private swarm configuration.
Table of Contents
- Installation
- Usage
- Setup Process
- Swarm Key Management
- Troubleshooting
- Advanced Topics
- Security Considerations
- Contributing
- License
Installation
Global Installation
To install the package globally using npm:
npm install -g ipfs-swarm-cliLocal Installation
To install the package locally:
npm install ipfs-swarm-cliUsage
Commands
The CLI supports the following commands:
ipfs-swarm-cli [command]Commands List:
init: Initialize IPFS swarm nodestart: Start IPFS daemonstop: Stop IPFS daemonstatus: Show swarm statusinfo: Show configuration and connection infotest: Test IPFS functionalityclean: Clean all IPFS data and configuration
Options
Init Command Options:
ipfs-swarm-cli init [options]--bootstrap: Set up as bootstrap node--regular: Set up as regular node--swarm-key <path>: Path to existing swarm key file--bootstrap-addr <addr>: Bootstrap node multiaddr--port <port>: Base port number (default: 4001)
Configuration
The tool creates a configuration file at ~/.ipfs-swarm/config.json with the following structure:
{
"nodeType": "bootstrap", // or "regular"
"swarmKey": "<path-to-swarm-key>",
"basePort": 4001,
"bootstrapMultiaddr": "<multiaddr>",
"nodeId": "<node-id>",
"lastStarted": "<timestamp>"
}Setup Process
Bootstrap Node
- Initialize the bootstrap node:
ipfs-swarm-cli init --bootstrap - This will generate a swarm key at
~/.ipfs-swarm/swarm.key - Share the swarm key with other nodes
- Start the daemon:
ipfs-swarm-cli start
Regular Node
- Initialize the regular node:
ipfs-swarm-cli init --regular --swarm-key <path-to-swarm-key> --bootstrap-addr <bootstrap-multiaddr> - Start the daemon:
ipfs-swarm-cli start
Swarm Key Management
Generating Swarm Key
The swarm key is automatically generated when initializing a bootstrap node. You can also generate it manually using:
ipfs-swarm-cli init --bootstrapSharing Swarm Key
- Copy the swarm key file from the bootstrap node:
scp ~/.ipfs-swarm/swarm.key user@remote:/path/to/swarm.key - Use the swarm key when initializing regular nodes:
ipfs-swarm-cli init --regular --swarm-key /path/to/swarm.key --bootstrap-addr <bootstrap-multiaddr>
Troubleshooting
Common Issues
1. Port Conflicts
- Symptom: Daemon fails to start with port already in use
- Solution:
- Check if port is in use:
netstat -tuln | grep <port> - Update configuration to use different port:
ipfs-swarm-cli init --port <new-port>
- Check if port is in use:
2. Connection Issues
- Symptom: Nodes cannot connect to each other
- Solution:
- Verify bootstrap multiaddr is correct
- Check firewall rules
- Ensure Tailscale is running (if used)
3. Daemon Not Starting
- Symptom: Daemon fails to start
- Solution:
- Check logs:
journalctl -u ipfs -f - Verify IPFS installation
- Clean up and retry:
ipfs-swarm-cli clean && ipfs-swarm-cli init
- Check logs:
Debugging
- Enable verbose logging:
DEBUG=* ipfs-swarm-cli <command> - Check IPFS configuration:
ipfs config show
Advanced Topics
Tailscale Integration
- Install Tailscale:
ipfs-swarm-cli init --regular --install-tailscale - Use Tailscale addresses for bootstrap nodes
Custom Ports
- Configure custom base port:
ipfs-swarm-cli init --port 4002 - Update firewall rules to allow traffic on new port
Security Considerations
Swarm Key Security:
- Never share the swarm key publicly
- Store swarm key securely
- Set proper permissions:
chmod 600 ~/.ipfs-swarm/swarm.key
IPFS Configuration:
- Restrict API access to localhost
- Disable MDNS discovery
- Use secure connection methods
Contributing
- Fork the repository
- Create a feature branch:
git checkout -b feature/MyFeature - Commit changes
- Push to the branch:
git push origin feature/MyFeature - Open a Pull Request
License
[Your License Here]
