4

Well, first of all, I can't keep monerod running on my VPS through an ssh session. When I close the ssh session it stops running.

Second question is do I need to open the port? Is it TCP or UDP port that needs to open? A quick command?

Seriously, the official guide is way too simple...it just tells to "simply run monerod" then you are running a node.

Thanks

1
  • 2
    Which guide? Re: ssh session, you need to daemonize using the --detach command or using screen . Google will help if that doesn't get you started.
    – Ginger Ale
    Jun 20, 2017 at 16:01

2 Answers 2

8

Method 1) A one-time start of monerod

You can use 'screen' to keep it running when you log out.

Ubuntu: apt-get install screen

CentOS: yum install screen

screen monerod --rpc-bind-ip <your external IP address> --rpc-bind-port 18089 --restricted-rpc --confirm-external-bind

Replace with the IP address of your VPS.

When monerod is running inside of screen, you can press Control-a-d to detach from the screen session and return to the command line. You use screen -r to reattach to the session.

Method 2) Keep monerod running perpetually

Create a new blank file called monerod-cron and add the following line. Be sure to enter the full path to your monerod binary and your external IP address.

0 * * * * <full/path/to/monerod> --detach --rpc-bind-ip <your_ip> --rpc-bind-port 18089 --restricted-rpc --confirm-external-bind

Example:

0 * * * * /usr/local/bin/monerod --detach --rpc-bind-ip 100.22.33.44 --rpc-bind-port 18089 --restricted-rpc --confirm-external-bind

Save the file and load it into your crontab by running crontab monerod-cron. This will start monerod automatically every hour. If monerod is already running, it will not start a second copy.

To view the monerod logfile: tail -f ~/.bitmonero/bitmonero.log

To view the crontab logfile: tail -f /var/log/cron

Notes

Your firewall will need to accept incoming connections to TCP port 18089.

There's some more info at https://moneroworld.com/#nodes

2
  • Can you explain what does "--rpc-bind-ip" do? It seems it then restricts the node to be used just by myself? But I was thinking the ip address of my home computer should be the ip address not the vps ip address? What if I need the node to be used just by myself for the moment?
    – Alex
    Jun 23, 2017 at 11:20
  • 1
    --rpc-bind-ip tells monerod which IP address to listen on for incoming connections. If you want to restrict use to yourself, you could use a firewall on your VPS to only allow access from your (home) IP address.
    – apexio
    Jun 23, 2017 at 14:54
2

@apexio's answer should work fine, but you might want to create a systemd unit if that's what your distro uses.

You can grab a pre-made systemd service spec from the source tree if you didn't want to write it yourself. Copy that file to /etc/systemd/system/monerod.service.

After that you can load it in with sudo systemctl daemon-reload, start it with sudo systemctl start monerod, and make it start on reboot with sudo systemctl enable monerod.

You can check if the daemon is running with sudo systemctl status monerod, and check the logs with sudo journalctl -u monerod.service.

Here's the commands that you need to run to download the spec, load it, enable it and start it.

sudo curl -O /etc/systemd/system/monerod.service https://github.com/monero-project/monero/raw/master/utils/systemd/monerod.service
sudo systemctl daemon-reload
sudo systemctl enable monerod
sudo systemctl start monerod

ninja edit: You probably want the daemon running as its own user, you can make one with sudo useradd -r -s /bin/false monero

Second question is do I need to open the port? Is it TCP or UDP port that needs to open? A quick command?

Everything will work if you left it as-is, but it would help the network if you opened ports. I believe you need to open TCP port 18080, but you can configure that with the --p2p-bind-port parameter.

1
  • Hello. I lost at the port number. Why is @apexio suggesting 18089 while you are suggesting leaving as it is suffices, and then adding 18080? On the other hand, what port number should I put in my monero GUI client side that is trying to connect to the remote node? I just tried 18080 and 18089 but both failed (with IP address being my VPS IP). It says "couldn't connnet to the daemon ".
    – Alex
    Jun 23, 2017 at 11:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.