How to secure your CentOS7 masternode server

in chaincoin •  7 years ago  (edited)

If you set up your CHC masternode using Max's (@highoncoins) tutorial, you might have gotten a message like this:

"Last failed login: Thu Jul 20 20:27:36 UTC 2017 from 123.183.209.136 on ssh:notty
There were 213 failed login attempts since the last successful login."

In case you haven't guessed yet, that is someone trying to guess your password and gain access to your root account. Which is not difficult if you have a crappy password... But worry not!

Here is a simple solution using key-pair authentication:

  1. On your local machine, open Terminal and type "ssh-keygen". Press 'enter' twice.
  2. SSH into your masternode server and type "mkdir -p ~/.ssh && sudo chmod -R 700 ~/.ssh/". Press 'Enter'.
  3. On your local machine, type "scp ~/.ssh/id_rsa.pub [email protected]:~/.ssh/authorized_keys" (replacing 000.000.000.000 with the your masternode's IP address). Press 'Enter'.
  4. In your masternode server CLI, type "exit" and press 'Enter'.
  5. SSH back into your masternode server and notice you didn't need a password!

...you are still not quite safe, yet

  1. In your masternode CLI, type " vi /etc/ssh/sshd_config" and press 'Enter'.
  2. Using your arrow keys, navigate down to 'PermitRootLogin', move the prompt to the 'y' in 'yes', and type "cw". Now type "without-password" and press 'Esc'.
  3. Go down to "#PubkeyAuthentication", move your prompt over the "#" and press 'x'.
  4. Go down to "PasswordAuthentication" (without "#"), move your prompt over the 'y' in 'yes', and type "cw". Now type "no" and press 'Esc'.
  5. Now type ":wq" to save and quit the text editor.

...one last step

  1. Type "systemctl restart sshd" and press 'Enter'.

Congrats! Now you are able to login to your server using key-pair authentication and those pesky hackers have no way to try brute-forcing your password.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Congratulations @ee92! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

You published your First Post

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

By upvoting this notification, you can help all Steemit users. Learn how here!

HELP HELP HELP!!!!
I’ve got 10 master nodes set up and running. However after changing the ports, 2 of my nodes have locked me out. One I tried to change the password and there must have been a mishap because no passwords are working to unlock it and the other node won’t load up with the old port or the new port. I can’t see how Ill be able to unlock access to either node. I guess my question is, can I shut down the server and just get those 1000 coins returned and re-establish the masternode? What happens to those coins if the server goes down?

Congratulations @ee92! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

You got a First Vote

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

By upvoting this notification, you can help all Steemit users. Learn how here!

Congratulations @ee92! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 2 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Vote for @Steemitboard as a witness to get one more award and increased upvotes!