This is a very rough guide that can help you secure a remote connection to your Monero node. This doesn't work for nodes you do not control. Instructions for Bitcoin are at the bottom.
- Works today with existing software.
- Doesn't expose your node's RPC port to the outside world.
- Desktop / Laptop & Android support.
- Works for both Monero and Bitcoin.
-
Setup your remote node on a server/vps and ensure it is working. You will need a static IP address or hostname.
- Install
monerod
- Configure rpc-login like this in
~/.bitmonero/bitmonero.conf
# Careful with the password as special characters can easily break your setup. # Avoid these chars and spaces: @`:"#'%$&=* # It doesn't have to be super secure. # Example: xmr:D9-x2.F6a rpc-login=USER_NAME:PASSWORD
- Start
monerod
and sync the whole blockchain.
- Install
-
Create a new user for tunneling:
useradd sshtunnel -m -d /home/sshtunnel -s /bin/true
- See Hardening below to secure this user account.
- Create a new ssh key pair:
ssh-keygen -t rsa -b 4096
- 4096 bit RSA is fine, as is
ed25519
(same curve used in Monero)
- 4096 bit RSA is fine, as is
- Show the pubkey:
cat ~/.ssh/id_rsa.pub
- Log into the remote node and append the pubkey to the user's authorized_keys file:
echo "YOUR_PUBKEY_LINE_HERE" >> ~/.ssh/authorized_keys
You should now be able to tunnel packets to your node.
-
Create an ssh tunnel forwarding port
18081
to the remote node:ssh -nNT -L 18081:localhost:18081 user@host
(changeuser@host
to the "username" you created above and name / ip address of your node)-n
Redirects stdin from /dev/null (actually, prevents reading from stdin).-N
Do not execute a remote command.-T
Disable pseudo-tty allocation.-L
Specifies that the given port on the local (client) host is to be forwarded to the given host and port on the remote side.
-
As long as it doesn't fail, you can then open up the Monero GUI and configure a "Remote node" as:
- Address:
localhost
- Port:
18081
- Click on "Show advanced", then add your
USER_NAME
andPASSWORD
for the RPC server (as configured in Remote node setup Step 1). - Click "Connect"
- Address:
If all went well, you should see the GUI start to load blocks after a minute or so. It may feel faster if you configure your node to use smaller batches of blocks, eg: block-sync-size=20
- Install Connectbot (Google Play | APK)
- Create a new ssh key.
- Somehow get the public key line into your remote
~/.ssh/authorized_keys
file. - Add a new host with the remote info
user@host
should be the "username" you created above and name / ip address of your node
- After the host is saved, you can then long-press on the hostname and select "Edit port forwards"
- Nickname: Monero rpc
- Type: Local
- Source port:
18081
- Destination:
localhost:18081
- Click "Create port forward"
- Go back to the main screen.
- Tap on the host you created to connect.
- You should see some stuff flash in the terminal, but then it just has a cursor in the middle and is black.
- Install the Monerujo Monero wallet and configure it to connect to:
RPC_USER:RPC_PASSWORD@localhost:1081
where:RPC_USER
is the username on the remote Monero nodeRPC_PASSWORD
is the password you created. Both can be found in the.bitmonero/monero.conf
file on your server / vps.
That should be everything, good luck!
You can duplicate the same setup above to run a full Bitcoin node and connect to it using Samourai Wallet and its Trusted Node feature.
Note: port number will be 8332
instead of 18081
above. Connectbot allows multiple Port forwards.
- You should restrict everything possible on your node to make sure the ssh tunnel user has no shell, and can only tunnel tcp traffic on the ports specified.
- Prevent password login on the server completely
Some useful settings to add to your server's ssh config file: /etc/ssh/sshd_config
# Disable passwords (only use public key auth)
PasswordAuthentication no
# Prevent root from logging in directly.
# Instead you should login as a another user, and use 'su' or 'sudo' to do what you need.
# Don't change this until you really know what you are doing, don't want to lock yourself out.
# PermitRootLogin no
# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no
# List all accounts you want to let use ssh (separated by a space).
AllowUsers my_normal_user sshtunnel
# Restrict the sshtunnel user to only access Monero and Bitcoin node ports.
Match User sshtunnel
PermitOpen localhost:18081 localhost:8332
PermitListen none
PermitTTY no
X11Forwarding no
AllowAgentForwarding no
ForceCommand /bin/false
Note: you need to restart ssh (usually sudo service ssh restart
) for changes to take place.
You can configure Orbot's VPN mode on your Android device to capture and route Connectbot traffic over the Tor network. This will allow the ssh tunnel connections to your full node to route through Tor. This only offers limited privacy if the server is in your name, but still helps. You do not need to configure a Tor hidden service for this to work.
See also Connecting your local wallet to your own daemon over Tor.
- Monerujo is working on adding Tor support. This could allow us to potentially remove Connectbot from the setup above, and instead run our node as a Tor hidden service. Connecting your local wallet to your own daemon over Tor: https://web.getmonero.org/resources/user-guides/tor_wallet.html
- I2P might become an option in the future.
This document comes with no guarantees, do your own homework. Feedback is welcome and appreciated.
WTFPL - See LICENSE for more info.