温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

NEO共识节点推荐搭建步骤是什么

发布时间:2021-12-10 18:48:01 来源:亿速云 阅读:101 作者:柒染 栏目:互联网科技

NEO共识节点推荐搭建步骤是什么,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。

共识节点推荐搭建步骤

远程访问

机器的远程访问仅限使用公钥与Yubico4/NEO实体公钥进行SSH认证。

硬件

出于安全考虑,节点不应在共享的机器上运行,而应在Deltalis, Equinix及A1 Arsenal等安全性较高的数据中心通过托管的方式运行。下列laaS供应商硬件配置可作为2018年的理想配置参考。

因为共识节点有计算功能,因此应定期检查网络硬件要求以保证最优性能。

如果无法进行托管,推荐laaS供应商与最低配置如下:

  • OVH EG-32

    • CPU: Intel Xeon E3-1270v6 – 4c/8t – 3.8GHz

    • RAM: 32GB DDR4 ECC 2133 MHz

    • SSD: softraid-1 2x450GB NVMe

    • NET: 1 Gbps

  • Packet Workhorse

    • CPU: Intel® Xeon E3-1240v5 – 4c/8t – 3.5GHz

    • RAM: 32 GB DDR3 ECC 1333 MHz

    • SSD: softraid-1 2x120GB Enterprise SSD

    • NET: 2 x 1 Gbps Bonded

  • Liquidweb

    • CPU: Intel Xeon E3-1275v6 – 4c/8t – 3.8GHz

    • RAM: 32 GB DDR4 ECC

    • SSD: softraid-1 2x240GB Enterprise SSD

    • NET: 1 Gbps

密码

使用密码管理工具存放本次搭建过程中所需的每个密码(推荐使用Lastpass和Dashlane),所有服务均应启用双因素认证和实体密钥(如有)。

所有密码均应设置高强度密码(使用此 lastpass方案)。

SSH认证密钥

仅限使用公钥访问SSH认证可起到密钥保护的作用,所以我们要求使用实体OpenPGP智能卡进行SSH认证。我们推荐使用Ubikey 4。有关Yubikey PGP的更多性能请参考官方文档.

  • 完整Windows指南

  • 完整Linux/MacOS指南

更改默认管理员PIN码 12345678 与PIN码 123456 为可记忆的安全密码。

将您的私钥添加到智能卡激活的认证代理服务后,gpg-agent就会与gpg2绑定——这是我们推荐的步骤。

服务供应商具体配置

打开供应商防火墙(不在OS设置中),设置为屏蔽全部,端口22、20333与10333除外。若有其他服务共享同一账户,请务必确保将节点放置在反关联性群组中。

Linux服务器配置

需给每个节点在两个辖区分别配置2个管理员。每个管理员都应有一个可以登录系统的专属用户和一个(SSH无权访问的)第三方共识用户,并且仅可通过该第三方共识用户访问共识节点的私钥(注意本指南使用的Ubuntu版本是16.04 LTS)。

首次登录时,设置一个强效根密码,但仅在遗失sudo密码(或进行撤销操作)时才需使用根密码;

su (sudo su on Ubuntu)
passwd

仍在使用su时

Ubuntu更新包:

apt-get update
apt-get upgrade

CentOS:

yum update

添加管理员用户(两个管理员重复操作):

useradd -m node
mkdir /home/node/.ssh
chmod 700 /home/node/.ssh

本指南是基于bash编制的,所以在shell下拉列表中将bash设为偏好值:

usermod -s /bin/bash node

从管理员的 ssh-add -L中将Yubikey公钥复制到authorized_keys:

vim /home/node/.ssh/authorized_keys

许可设置:

chmod 400 /home/node/.ssh/authorized_keys
chown node:node /home/node -R

设置管理员密码(这就是sudo密码):

passwd node

接下来我们就可以设置管理员的sudo了,添加 %sudo 群组,注释非 root的任何其他群组时使用#:

visudo

文件格式如下:

# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults        env_reset
Defaults        mail_badpass
Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) ALL

# Members of the admin group may gain root privileges
#%admin ALL=(ALL) ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d

将管理员添加到sudo群组:

usermod -aG sudo node

需登录并登出管理员账户后才能完成更新:

su -l node
exit

再回到su,现在设置为仅可通过公钥与管理员登录SSH:

vim /etc/ssh/sshd_config

应添加下列行或在原有的基础上修改成如下形式,在AllowUsers中添加所有管理员并用空格键隔开:

X11Forwarding no
PermitRootLogin no
PasswordAuthentication no
AllowUsers node
LoginGraceTime 30
AllowTcpForwarding no
TCPKeepAlive no
AllowAgentForwarding no
DebianBanner no
Banner /etc/ssh/sshd-banner

设置SSH的法律声明:

echo "WARNING:  Unauthorized access to this system is forbidden and will be
prosecuted by law. By accessing this system, you agree that your actions
may be monitored if unauthorized usage is suspected." >> /etc/ssh/sshd-banner

添加用户运行共识节点:

useradd consensus
mkdir /home/consensus
chown consensus:consensus /home/consensus -R

为共识节点创建一个非常强效的密码,应可安全地被两个管理员共享:

passwd consensus

su的最后一步就是以管理员身份登录后重启SSH。

sudo systemctl restart sshd.service

以管理员身份登录时

防火墙

首先在Debian(Ubuntu)中安装防火墙并锁定节点:

sudo apt-get install ufw

CentOS:

sudo yum install epel-release
sudo yum install ufw

vim /etc/default/ufw中将IPV6设为yes,并设置为仅允许使用端口:

sudo ufw default deny incoming
sudo ufw allow ssh
sudo ufw allow 10333
sudo ufw allow 20333
sudo ufw disable
sudo ufw enable
自动安全更新

Ubuntu:

sudo apt-get install unattended-upgrades
sudo vim /etc/apt/apt.conf.d/10periodic

更新以匹配:

APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::AutocleanInterval "7";
APT::Periodic::Unattended-Upgrade "1";

禁止不安全的自动更新:

sudo vim /etc/apt/apt.conf.d/50unattended-upgrades

更新,未注释的行有且仅有以下几行:

Unattended-Upgrade::Allowed-Origins {
    "${distro_id}:${distro_codename}";
    "${distro_id}:${distro_codename}-security";
    "${distro_id}ESM:${distro_codename}";
};

CentOS:

安装yum-cron并允许安全包更新:

sudo yum -y install yum-cron
sudo systemctl start yum-cron
sudo systemctl enable yum-cron
sudo nano /etc/yum/yum-cron.conf

更改设置以匹配:

update_cmd = security
apply_updates = yes
emit_via = email
email_to = YOUR_EMAIL_TO_RECEIVE_UPDATE_NOTIFICATIONS

有更新时,使用email_to功能插入你想发送提醒的邮件地址。

fail2ban

接下来我们就来安装fail2ban,这个工具可禁止防火墙上的可疑IP。该工具的默认值就可使用,因此简单的安装就够了。Ubuntu:

sudo apt-get install fail2ban

CentOS:

sudo yum install fail2ban
双因素认证

将2FA与SSH的实体OpenPGP密钥相结合是强效认证设置。在Ubuntu中使用下列代码安装:

sudo apt-get install libpam-google-authenticator

CentOS (启用epel——同上):

sudo yum install google-authenticator

安装完毕后,以管理员身份运行指令时遵循每步指令,(回答y/y/y/n/y),先以管理员身份(两个)进行这步操作,完成后再更新PAM获得2FA:

google-authenticator

接下来编辑SSH配置来获得2FA设置许可:

sudo vim /etc/pam.d/sshd

在文件结尾添加以下行:

auth required pam_google_authenticator.so

在Ubuntu中放入密码提示的注释行:

# Standard Un*x authentication.
#@include common-auth

CentOS:

#auth       substack     password-auth

编辑sshd_config文件要求进行2FA认证:

sudo vim /etc/ssh/sshd_config

编辑文件允许认证,并添加认证方法行:

ChallengeResponseAuthentication yes
AuthenticationMethods publickey,password publickey,keyboard-interactive

重启SSHD服务:

sudo systemctl restart sshd.service

在保持当前SSH窗口运行的同时打开另一个窗口,并登录以确认设置能正确运行。

监视

保持对共识节点的监视对于发现问题及改善NEO项目而言是至关重要的。我们仅会通过SSH通道安装并访问网络数据库(保留防火墙拦截设置)。

安装预购建静态版本(以减少攻击面并杜绝不必要的依赖性):

bash <(curl -Ss https://my-netdata.io/kickstart-static64.sh)

访问方法是创建SSH通道并打开浏览器访问localhost:19999:

ssh -f node@SERVERIP -L 19999:SERVERIP:19999 -N

NEO共识节点推荐搭建步骤是什么

登录成功邮件通知
sudo apt-get install mailutils

CentOS:

sudo yum install mailx

编辑默认bash档案:

sudo vim /etc/profile

在文件结尾添加以下行,编辑邮箱使其可接收登录通知:

SIP="$(echo $SSH_CONNECTION | cut -d "> 
 Logwatch在Ubuntu上配置logwatch以发送节点的日常活动总结(通常无活动):sudo apt-get install logwatch CentOS:sudo yum install logwatch 现在添加cron job将总结发送到你的邮箱:sudo vim /etc/cron.daily/00logwatch 将默认执行命令变更为:/usr/sbin/logwatch --output mail --mailto YOUR@EMAIL.HERE --detail high  黑名单USB与防火墙存储我们会把不需要的模块放入黑名单以减少攻击面,WiFi和蓝牙通常已经与服务器内核切断了(需验证!),因此仅需关闭USB存储。sudo vi /etc/modprobe.d/blacklist.conf 添加以下行:blacklist usb-storage
blacklist firewire-core  安装并运行共识节点在Unbuntu上安装前提条件:sudo apt-get install unzip sqlite3 libsqlite3-dev libleveldb-dev libunwind-dev CentOS:sudo yum install unzip leveldb-devel libunwind-devel 以共识节点用户的身份登录:su consensus
cd ~ 在发行版中下载、验证校验和、解压最新版neo-cli客户端:wget https://github.com/neo-project/neo-cli/releases/download/v2.5.2/neo-cli-YOURDISTRIBUTION.zip
sha256sum neo-cli-YOURDISTRIBUTION.zip
unzip neo-cli-YOURDISTRIBUTION.zip
cd neo-cli
chmod u+x neo-cli 复制节点运行的设置(测试网或主网):mv protocol.json protocol.json.back
cp protocol.testnet.json protocol.json 如果这是首次操作,你需要给共识节点创建钱包:./neo-cli
neo> create wallet /home/consensus/cn_wallet.json
password: SOMESTRONGPASSWORD
password: SOMESTRONGPASSWORD 复制start_consensus脚本:cd ~
wget https://raw.githubusercontent.com/CityOfZion/standards/master/assets/nodes/start_consensus.sh
chmod u+x start_consensus.sh 编辑目录使其与你的钱包文件地址及密码匹配。现在就可以在supervisord的控制下在Ubuntu上运行了:sudo apt-get install supervisor CentOS:sudo yum install supervisor 配置supervisord以执行start_consensus(在需要的情况下编辑文件):wget https://raw.githubusercontent.com/CityOfZion/standards/master/assets/nodes/supervisord.conf
chmod 700 supervisord.conf
cp supervisord.conf /etc/supervisord.conf
sudo supervisord 添加初始脚本以便在系统重启时自动运行。这就是全部步骤,现在登出服务器并仅在必须部署更新或检测到恶意行为时再重新登录。 其他安全推荐GRUB密码磁盘加密开启TCP SYN Cookie功能(net.ipv4.tcp_syncookies = 1 -> /etc/sysctl.conf)原文翻译自CoZ:https://github.com/CityOfZion/standards/blob/master/nodes.md

关于NEO共识节点推荐搭建步骤是什么问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注亿速云行业资讯频道了解更多相关知识。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

neo
AI