We're proud to announce that our community member @sushi2k7
made a detailed Raspbian setup guide for you guys!
Hello StealthCoin community,
I want to share my Raspbian setup with you.Things I got done and want to share here right now are:
- Create an account on no-ip.com
- Configure your router
- Install a ssh client on a Windows machine
- Move the entire root partition to an USB-drive
- Install the no-ip autoupdate-client on your Pi
- Download and install Berkeley Database
- Get the Stealthcoin daemon and create StealthCoin.conf
- Autostart the deamon on every boot
- Basic commands explained
- Using aliases to ease the handling a bit.
- Download a ssh client from Android Playstore, configure and use it.
- Create scripts to secretly unlock and spend coins.
- Do a cron-job to backup the chain every midnight.
This tutorial begins after a fresh installed Raspbian where you already have setup a ssh connection.
There are many tutorials out there, even on YouTube.
Configure your router:Please use the manual of your router to portfoward incomming traffic (TCP) on port 22 to your Pi.
Install a ssh client on a Windows machine:My favourite ssh client is the MobaXterm client (Free Personal Edition is very ok for me) because of the tabbed windows.
You can get it here:
http://mobaxterm.mobatek.net/download.htmlOf course you can use the minimalistic putty for ssh:
https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
Configure mobaxterm:![](https://ip.bitcointalk.org/?u=https%3A%2F%2Fs19.postimg.org%2F41cz68o0z%2Fssh_client.png&t=665&c=Yxnh4QDRQAPzWg)
Hit Session, SSH, insert your Pi hostname raspberrypi (i changed mine to rpi), check the username checkbox and enter pi. Hit Ok.
Starting a session:![](https://ip.bitcointalk.org/?u=https%3A%2F%2Fs19.postimg.org%2F5ri82i1er%2Fssh_client-2.png&t=665&c=SdQJ7xQidD3ogw)
Click session on the left side and doubleclick your sessionname. You will be asked for your password and also to save it.
If your host is reachable, you will see your bash prompt.
You should change the CTRL-V shortcut in Moba, else it will popup the console window everytime you want to paste something:
For safety we change the userpassword. Note: The passwords are always hidden.
Connect to pi with:hostname: raspberrypi
username: pi
password: raspberry
In bash type
At first you will be asked for the current password (raspberry)
Then the new password and at last the confirmation of the new password.
Why moving root to an USB-drive?The sdcard has very less write cycles before the data on it will get corrupt. USB-drives have a greater write speed with a much greater lifespan.
The sdcard will still be needed but for booting only.
The initial steps are:Format the usb-drive with EXT4 filesystem.
Copy the root partition to an USB-drive and tell the sdcard where to find the new root-partition.
I used a second sdcard with a fresh Raspbian, a sdcard to USB-A adapter and the USB-drive to copy the root-partition to the USB-drive.
At first we need to identify the drives.
Boot your Pi with the alternative sdcard plugged in.
I used the command mount to see how the card and drive were mounted.
In my case the root-partition on the sdcard (/dev/sdb2) was mounted as /media/pi/root
The USB-drive (/dev/sda1) was mounted as /media/pi/5e8b5219-d7d7-416b-8838-377f7918c322 (Just the identnumber of the drive).
Now we format the USB-drive with EXT4 filesystem by doing:pi@rpi:~ $ mkfs.ext4 /dev/sda1
Now we COPY all content from the root-partition to the USB-drive. If something went wrong, we have everything still untouched on the sdcard.
The command: pi@rpi:~ $ sudo cp -avr /media/pi/root/* /media/pi/5e8b5219-d7d7-416b-8838-377f7918c322/
The ending slash / is very important after the id.
next we do a ![](https://ip.bitcointalk.org/?u=https%3A%2F%2Fs19.postimg.org%2F9p5hrwo83%2Fblkid.png&t=665&c=y94mEyHebvQJaw)
The important line is the one with the long id that matches with the /media/pi/5e8b5219-d7d7-416b-8838-377f7918c322
But we need the PARTUUID= id in this line. Mine is "c3072e18-01"
Now we need to replace the PARTUUID in the /boot/cmdline.txt
pi@rpi:~ $ sudo nano /boot/cmdline.txt
![](https://ip.bitcointalk.org/?u=https%3A%2F%2Fs19.postimg.org%2Fwf4mkw7fn%2Fcmdline.png&t=665&c=qQOY2tZ4Y3R6Kw)
CTRL&O will save the file, press enter to accept the filename
CTRL&X will exit nano
Now shutdown the Pi with:pi@rpi:~ $ sudo shutdown now
Change the sdcards and fire up your Pi again.
After login do a mount command.
If /dev/sda1 is mounted as / everything is gone right (if there was a mistake, the system wont have booted). You might format the sdcard/root partition and use it to store some files.
To see your USB-drive performance you can do a:
pi@rpi:~ $ dd if=/dev/zero of=~/TMP bs=1M count=400
it will show you the amount that been written, the time in seconds needed and the writingspeed in MB/s.
Downloading and installing Berkeley DB 4.8.30
I use the bin folder to download and make the database:
do:pi@rpi:~ $ mkdir ~/bin
pi@rpi:~ $ cd ~/bin
then:pi@rpi:~/bin $ wget http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz
pi@rpi:~/bin $ tar xzvf db-4.8.30.NC.tar.gz
pi@rpi:~/bin $ cd db-4.8.30.NC/build_unix/
pi@rpi:~/bin/db-4.8.30.NC/build_unix/ $ ../dist/configure --enable-cxx
pi@rpi:~/bin/db-4.8.30.NC/build_unix/ $ make -j2
after make finished, do:pi@rpi:~/bin/db-4.8.30.NC/build_unix/ $ make install
Download and install the Noip-Autoupdate client:Create an account on no-ip.com (the free account needs you to hold your hostaddress alive monthly.):
Go to
https://noip.com click signup at the right top. Then you need to specify your login and the DynDNS adress with which you want to point to your Raspbian.
After clicking the activation link in your email inbox your are ready to go.
Now:pi@rpi:~ $ cd ~/bin
pi@rpi:~/bin $ wget http://www.no-ip.com/client/linux/noip-duc-linux.tar.gz
pi@rpi:~/bin $ tar vzxf noip-duc-linux.tar.gz
pi@rpi:~/bin $ cd noip-2.1.9-1
pi@rpi:~/bin/noip-2.1.9-1 $ sudo make
pi@rpi:~/bin/noip-2.1.9-1 $ sudo make install
After doing 'sudo make install' you will be asked for your login details (email and password) and update intervall.
The update intervall must be at least 5 minutes.
Now we do a cronjob to start it every (re)boot.
Command:pi@rpi:~/db-4.8.30.NC/build_unix/ $ cd ~
pi@rpi:~ $ crontab -e
Add: @reboot sudo noip2
![](https://ip.bitcointalk.org/?u=https%3A%2F%2Fs19.postimg.org%2Feht38kn1f%2Fcronjob.png&t=665&c=T-IZq2yycvIsSQ)
CTRL+O
CTRL+X
Getting Stealthcoin daemon ready:Change to your bin folder:
pi@rpi:~ $ cd ~/bin
pi@rpi:~/bin $ wget https://github.com/StealthSend/Stealth/releases/download/v2.1.0.1/Stealth-Daemon-2.1.0.1-Raspbian.tar
Unpack now:
pi@rpi:~/bin $ tar vxf Stealth-Daemon-2.1.0.1-Raspbian.tar
create the folder .StealthCoin and StealthCoin.conf file:pi@rpi:~ $ mkdir ~/.StealthCoin
pi@rpi:~ $ nano ~/.StealthCoin/StealthCoin.conf
enter the following lines:rpcuser=anything
rpcpassword=anything
server=1
daemon=1
CTRL&O
CTRL&X
download the bootsrap file from
https://drive.google.com/file/d/0B8rWObF4xz1YRzd1VVNXM0JrWEE/view?usp=sharingunzip it with 7zip (
http://www.7-zip.org/)
and put the bootstrap.dat into the ~/.StealthCoin folder
Autostart the daemon on boot:pi@rpi:~ $ sudo nano /etc/rc.local
Before the line Exit 0 add the following:![](https://ip.bitcointalk.org/?u=https%3A%2F%2Fs19.postimg.org%2Fyqlireso3%2Frc_local.png&t=665&c=h6cbP4ThALy0sA)
will run the daemon as user pi, else it will be run as root.
The & at the end is necessary to run the deamon in the background. If you miss the & at the end, your pi will stuck at boot.
I saw the & behind the double quotes and before... This way works for me, so i leave it this way.
CTRL&O
CTRL&X
Aliases will help us later when we want to control or check our pi with ssh:
edit your .bash_aliases. This file, if existing, will be loaded automatically:
pi@rpi:~ $ nano ~/.bash_aliases
We create the following aliases:scd(){
~/bin/StealthCoind "$@"
}
alias scdlog="tail -f ~/.StealCoin/debug.log"
CTRL&O
CTRL&X
scd alone will start the deamon. But we can give our commands to this alias too.
scdlog will continously read and output the debug.log file
After starting the daemon, it needs around 2 minutes until the server is started and responds to your commands. The Tor connection will be established first.
The command will output all available commands.
The mainly used commands that I use are (scd command is from aliases section above):scd getinfo (shows main informations like balance, ip-address (onlion), number of connections, amount of stake and some more)
scd walletpassphrase 'passphrase' seconds true (opens the wallet, if true is set, it's only for staking.)
scd walletlock (Immediately locks the wallet)
scd stop (stops the daemon)
scd sendtoaddress destinationaddress amount comment (sends coins to the specified address with the given amount.)
now we will install an Android SSH-Client. I only have an Android powered Mobilephone, so I only can recommend an Android SSH-Client.
Install Terminus SSH-Client from Playstore. This client disables word prediction, this way we can secretly enter our passphrases.
Open the client. Hit the plus in the lower right corner.
Then hit "New Host".
Alias will be shown on main screen.
In Hostname field enter the previous created no-ip address or raspberrypi if used in LAN. (yoursomething.hopto.org)
Now hit SSH.
Port: 22
Username :pi
Password: your changed password from the beginning
Everything else can stay unchanged.
Now we create 2 bash scripts. First to unlock our wallet for staking w/o visible passphrase (unlock in console with the walletpassphrase command will show the passphrase visible to everyone), second to do a transaction via SSH:
Connect to your pi with your computer.
Then do a:pi@rpi:~ $ nano ~/.StealthCoin/scdpassstake.sh
enter the following listing:#! /bin/sh
. ~/.bash_aliases
scd walletlock #make sure wallet is locked, so StealthCoind wont throw an error
echo "Wallet locked"
echo "Enter Walletpassphrase (hidden): "
read -s PASSPHRASE #read the users input but hide it (-s)
scd walletpassphrase ${PASSPHRASE} 31536000 true #open the wallet for 31536000 seconds (365 days) for staking only
echo "Wallet opened for staking (365 Days)"
CTRL&O
CTRL&X
now we need to make the script executable with:pi@rpi:~ $ sudo chmod +x ~/.StealthCoin/scdpassstake.sh
Create the spending script:pi@rpi:~ $ nano ~/.StealthCoin/scdsendto.sh
again the listing:#! /bin/sh
. ~/.bash_aliases
#3 variables are needed to give: Destinationaddress, amount to spend and own comment
scd walletlock
echo "Wallet locked"
echo "Enter Walletpassphrase (hidden): "
read -s PASSPHRASE
scd walletpassphrase ${PASSPHRASE} 180
echo "Wallet opened for sending (180 sec)"
echo "Destinationaddress: "
read ADDRESS
echo "Amount: "
read AMOUNT
echo "Comment: "
read COMMENT
echo ${COMMENT} >> ~/.StealthCoin/tx_ids.txt #write the comment into the tx_ids.txt file
scd sendtoaddress ${ADDRESS} ${AMOUNT} ${COMMENT} >> ~/.StealthCoin/tx_ids.txt #write the transactionid into the tx_ids.txt file
echo " " >> ~/.StealthCoin/tx_ids.txt
sleep 3
echo "If sending was successful, comment tx-id will be stored in ~/.StealthCoin/tx_ids.txt"
scd walletlock
sleep 3
scd walletpassphrase ${PASSPHRASE} 31536000 true
echo "Wallet opened for staking (365 days)"
CTRL&O
CTRL&X
pi@rpi:~ $ sudo chmod +x ~/.StealthCoin/scdsendto.sh
now we add the commands to our .bash_aliases because they must be executed with bash <filename>, else we get an error because of the "read -s" unknown by sh.
pi@rpi:~ $ nano ~/.bash_aliases
add the following lines:alias scdstake='bash ~/.StealthCoin/scdpassstake.sh'
alias scdsendto='bash ~/.StealthCoin/scdsendto.sh'
CTRL&O
CTRL&X
if you do now:you will be asked for your passphrase (hidden) and then it will open your wallet for staking.
with:you will be asked for the destination stealthcoinaddress, the amount and a comment.
I STRONGLY advise you that you have already copied the destinationaddress to avoid that the deamon already closed your wallet, befor you send the transaction command.
I already have a cronjob running that does a backup of my ~/.StealthCoin folder every midnight, but it's actual a backup to the USB-drive itself.
But i will post how to do it anyway. So you can change the destination of the backup to your needs:
pi@rpi:~ $ nano ./StealthCoin/backup.sh
into this file write:tar -zcvf ~/StealthCoin_bak.tar.gz ~/.StealthCoin/
change the ~/StealthCoin_bak.tar.gz to your desired destination
make it executable:pi@rpi:~ $ sudo chmod +x ~/.StealthCoin/backup.sh
now the cronjob for it:
add the line 0 0 * * * /home/pi/.StealthCoin/backup.sh
you must write the full path. Don't use the ~.
it means: do this script every 0 hour, 0 minute, every day a month, every month and every day a week
Sooo now i wish everyone a lot of fun with this tutorial.
One advise to you:Before asking questions here and wait hours for a response, ask google first.