Category Archives: BitCoin

BitCoin Mining Through an SSH Tunnel on Mac OS X with BFGMiner & TripleMining.com

  1. Signup for a mining pool.  If this article helped you, please signup for a mining account at http://hojothum.triplemining.com to join my pool.  You can signup by yourself on TripleMining.com or for another pool, but I’d appreciate you joining my pool or donating BitCoin to “1H3scrfsKd7xJYCA38KxieBTRVRsVw3P9q” if the article helped you out.
  2. Download a BitCoin client and create your wallet: http://bitcoin.org/en/choose-your-wallet.  I encrypted my wallet via the menu option “Settings->Encrypt Wallet” so that no-one can make changes to my wallet or initiate payments without my password.  I’m using BitCoin-Qt.app because it seemed to be the most official one when I started mining.  If this is the first time you’re launching it it will take a while for it to sync up all the transactions from the network.
  3. In your BitCoin client under “Receive Coins” make note of the “Address” and set it in your mining pool account (i.e. triplemining.com) so that the pool knows where to send your coins.  On TripleMining.com you do this under the “Account” page in the “Change payout address” section.
  4. Install a tunnel plist into ~/Library/LaunchAgents/com.ssh.tunnels.plist to tunnel an open outgoing port to the mining site you wish to use.  Here we tunnel to stratum.triplemining.com which uses port 3334 See the example Launch-Agent plist below as a guide. The command to load the plist on the command line in Terminal is
    launchctl load -w -S Aqua ~/Library/LaunchAgents/com.ssh.tunnels.plist

    This configuration assumes you have SSH keys setup on the server for the tunnel to connect without entering a passphrase.  ”tunnel-server.com” should be replaced with the name of your server. We’re essentially running:

    ssh -f tunnel-server.com -N -L 8081:stratum.triplemining.com:3334

    since we know the port 8081 is passed through the firewall. If you know a different port is available, then change 8081 to the port you know is open. Setting up a server and the SSH keys in order to tunnel your port is outside of the scope of this post.

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
    "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>Label</key>
        <string>com.ssh.tunnels</string>
        <key>KeepAlive</key>
        <dict>
              <key>NetworkState</key>
              <true/>
        </dict>
        <key>LimitLoadToSessionType</key>
        <string>Aqua</string>
        <key>ProgramArguments</key>
        <array>
            <string>/usr/bin/ssh</string>
                    <string>tunnel-server.com</string>
                    <string>-N</string>
                    <string>-L</string>
                    <string>8081:stratum.triplemining.com:3334</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
    </dict>
    </plist>
    
  5. Build the miner.  I’m assuming you know what MacPorts is and that you have it installed. I’m going to list straight commands here to build on Mac OS X as I’m also assuming the reader has enough prior knowledge with the command line (Terminal) to follow along:
    mkdir -p ~/Miner/Applications
    cd ~/Miner/Applications
    
    git clone https://github.com/luke-jr/bfgminer
    cd bfgminer
    git checkout bfgminer-3.0.2
    
    sudo port install jansson
    sudo port install curl
    
    ./autogen.sh
    ./configure PKG_CONFIG_PATH=/opt/local/lib/pkgconfig/jansson.pc:/opt/local/lib/pkgconfig/libcurl.pc
    make all
    
  6. Now that you’ve built the miner and you have the “bfgminer” binary it’s time to run it and mine some BitCoins.  Create a worker in your  mining pool for this miner to connect to (i.e. “https://www.triplemining.com/workers“).  Run the miner against the worker config you created:
    cd ~/Miner/Applications/bfgminer
    export DYLD_LIBRARY_PATH=./libblkmaker/.libs/
    ./bfgminer -o http://127.0.0.1:8081 -u [username] -p [password]
    

    [username] and [password] refer to the username and password of the miner on your mining pool workers page (i.e. “https://www.triplemining.com/workers“). Note that the worker username is prepended with your username. These credentials need to be correct for the miner to connect to the pool properly. If you changed the port number for the Launch Agent SSH tunnel make sure you change 8081 here to the port you used.  Read the bfgminer README to see some additional command line options to tweak the miner.

  7. Join My Pool: http://hojothum.triplemining.com
    Donate BitCoin: 1H3scrfsKd7xJYCA38KxieBTRVRsVw3P9q

    UPDATED: The LaunchAgent XML was corrected to match the SSH tunnel description text.