HOWTO Run Sia host on headless Linux server (Ubuntu)
-
This might be helpful for anyone that wants to run Sia as a host on a Ubuntu server (now updated for 16.04 LTS). I'll maintain this thread, as well as the GitHub Gist where this is copied from.
Last updated: August 14, 2016
Create user siad
adduser siad
su siadDownload and install Sia binaries
cd ~
wget https://github.com/NebulousLabs/Sia-UI/releases/download/v1.0.2/Sia-UI-v1.0.2-linux-x64.zip
unzip Sia-UI-v1.0.2-linux-x64.zip
mv Sia-UI-linux-x64/ Sia/Configure systemd so that siad runs on boot (and restarts in case of a crash)
Create siad.service
nano ~/.config/systemd/siad.serviceAdd these lines to siad.service
Description=Sia Daemon [Service] ExecStart=/home/siad/Sia/siad WorkingDirectory=/home/siad/Sia/ Restart=always [Install] WantedBy=multi-user.target Alias=siad.serviceNote: If you are also running Sia-UI, change WorkingDirectory above to:
WorkingDirectory=/home/siad/.config/Sia-UI/sia/Exit to root user
exitConfigure firewall (if ufw is in use)
ufw allow 9982Start siad as a service
systemctl daemon-reload
systemctl enable ~/.config/systemd/siad.service
systemctl start siad.serviceSia should now be running as a service which can be confirmed with:
curl -s -X GET http://localhost:9980/consensus -A "Sia-Agent"Next, lets configure siad by changing to user
siad:
su siad
cd ~/SiaCreate new wallet:
./siac wallet initCopy down the seed to a safe location! You will need this to unlock your wallet.
Unlock wallet (might take upwards to a minute, but probably less):
./siac wallet unlockCreate a new wallet address that you can receive funds on:
./siac wallet addressConfigure your host settings:
See [https://blog.sia.tech/how-to-run-a-host-on-sia-2159ebc4725)Confirm your host status:
./siac hostAnnounce your host:
./siac host announceIf you want to run Sia on a different port and/or host, do this instead:
./siac host announce [hostname]:[port]Wait a few minutes/hours and confirm other nodes see you:
http://siapulse.com/page/network
-
cool, thanks for the howto. Looks like this will mostly work for other systems as well, just substitute the package manager as needed.
-
For the hosting to work wouldn't you have to leave the wallet unlocked?
-
yes, you do. Would also be good to see a tutorial here for setting up dydns
-
very valuable
just how to push files to sia headless ?
-
When working with headless machines, you are going to be using
siacto interact with all files. It's strongly recommended that you make use of the help dialogs.siac -hwill give a list of commands.Sia Client v0.5.0 Usage: siac [flags] siac [command] Available Commands: version Print version information stop Stop the Sia daemon hoSia Client v0.5.0 Usage: siac [flags] siac [command] Available Commands: version Print version information stop Stop the Sia daemon host Perform host actions hostdb List active hosts on the network miner Perform miner actions wallet Perform wallet actions renter Perform renter actions gateway Perform gateway actions status Print the current state of the daemon Flags: -a, --addr string which host/port to communicate with (i.e. the host/port siad is listening on) (default "localhost:9980") Use "siac [command] --help" for more information about a command. st Perform host actions hostdb List active hosts on the network miner Perform miner actions wallet Perform wallet actions renter Perform renter actions gateway Perform gateway actions status Print the current state of the daemon Flags: -a, --addr string which host/port to communicate with (i.e. the host/port siad is listening on) (default "localhost:9980") Use "siac [command] --help" for more information about a command.Subcommands also give help
siac renter -h
Upload, download, rename, delete, load, or share files. Usage: siac renter [flags] siac renter [command] Available Commands: queue View the download queue delete Delete a file download Download a file list List the status of all files load Load a .sia file loadascii Load an ASCII-encoded .sia file rename Rename a file share Export a file to a .sia for sharing shareascii Export a file as an ASCII-encoded .sia file upload Upload a file Global Flags: -a, --addr string which host/port to communicate with (i.e. the host/port siad is listening on) (default "localhost:9980") Use "siac renter [command] --help" for more information about a command.To upload a file,
siac renter upload [source] [siapath], for more information runsiac renter upload -h
-
I like systemd (oddly enough), so I've set up my sia host using systemd directly instead of employing supervisord to make sure it stays running.
It is enough to create a user I called "sia", as described above, copy siad in /usr/local/bin, and then put the following in /etc/systemd/system/sia.service:
[Unit]
Description=Sia daemon
After=network.target[Service]
Type=simple
User=sia
Nice=5
WorkingDirectory=/home/sia/my-host-directory
ExecStart=/usr/local/bin/siad
Restart=on-failure
RestartSec=30[Install]
WantedBy=multi-user.targetThen issue "systemctl daemon-reload".
This will start siad automatically after boot, and restart it if it fails.
-
This link is not working anymore:
Configure your host settings:
See http://blog.sia.tech/2016/05/26/how-to-run-a-host-on-sia/Probably URL structure on the blog changed and this is it:
https://blog.sia.tech/how-to-run-a-host-on-sia-2159ebc4725
-
I went ahead and updated the link in the parent post. Should be noted that this guide is over a year old and hosting looks a lot different now. It's mostly still going to be relevant, but we're due for another guide soon.
-
I was able to set up a node following that post and haven't encountered any problem. So seems ok to me.
-
one short question about
./siac host announce
do I have to execute this after every sytsem reboot?
-
@menace_one: you have to execute this only once after setting up a new host. But you have to unlock your wallet after each restart.
-
What is the way to auto-unlock the hosting wallet?
My siad is working fine on the headless box. But to be a good host it needs to come up as soon as possible after a reboot or downtime. Sometimes it happens that I even do not notice that there was a power outage, as the server comes up and all services are started.
So, how to automate the wallet unlocking for the hosting service to be operational after starting?
-
One way to to it would be to put a watch into cron like evry 5 minute or so using siac,
If ! wallet unlocked
ulock it.
-
@brisk
My question was more about feeding the password to siac...
Can I do it on command line (in batch file/shell script)?
-
sure easy peasy
(echo "lakes romance ... ) | siac wallet unlock
-
@brisk
Oh, thanks. It works this way.
I thought there should be a command line parameter for siac such as siac wallet unlock -p <password> .From the other side it wouldn't be more secure as echoing from a script.
As I don't like storing cleartext passwords in script files, there should be a more elegant way to do this.
I know, most of database accessing software is storing the cleartext db access password in a conf file and it may be even less secure than storing it in the startup script.So, perhaps, when the devs have more time... Could a key file be generated from something machine specific and the wallet password? So the user should generate such key file from his wallet password when the wallet is moved to another machine.
Or better, the hosting process should be capable to run on a "partially locked" wallet, as no user approval is needed for from the hosting process originating transactions anyway. The collateral would be locked at the moment the user makes changes to his hosting parameters -price, size etc or/and turns accepting contracts on (which can happen only when the wallet is already unlocked). And these locked SC are accessible for the hosting process even if the wallet is locked.
-
I dont know if an attacker is in he (or she) is in. Imo best to do here is to make sure the online wallet always have pretty limited funds and you make a process of refilling/draining it when needed.
Also it a general bad practice to send passwds as arguments, anyone can see them using tools like top then ( my echo just as bad) better would be to read it from a file or env variable on ly accessable to current user.
-
Hello @brisk thanks for your thoughts,
can you explain how an attacker, which overtook a local (non root) user, could read the echo from your suggested command line?
Would it make a difference wheather script is executed by root or a non-root user?greetings
-
-
What about
Could not announce host: insufficient balance
when trying to annouce ?