暗影之夜 的文章

升级golang

0 条评论 未分类 无标签 暗影之夜
[root@localhost local]# go version
go version go1.21.4 linux/amd64
[root@localhost local]#
  • 命令行查看旧版本go存放路径
[root@localhost local]# which go
/usr/local/go/bin/go
[root@localhost local]# 
  • 解压文件到 /usr/local/
tar zxf go1.22.0.linux-amd64.tar.gz -C /usr/local/

为被监控虚拟机部署 node_exporter

0 条评论 乱七八糟 无标签 暗影之夜
  • 解压到/usr/local
##解压并移动到/usr/local
##解压并移动到/usr/local
tar -xzvf node_exporter-1.3.1.linux-amd64.tar.gz 
mv node_exporter-1.3.1.linux-amd64 /usr/local/node_exporter
  • 在/usr/local/node_exporter/目录下新建node_exporter.service文件并写入以下内容,同样配置这个文件是为了能用systemctl 管理服务
cd /usr/local/node_exporter
touch node_exporter.service
vi node_exporter.service
  • 写入内容
##node_exporter.service
[Unit]
Description=Node Exporter
After=network.target
Wants=network-online.target

[Service]
Type=simple
User=root
ExecStart=/usr/local/node_exporter/node_exporter 

Restart=on-failure
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target

graylog 最大检索数不能大于10000的问题

0 条评论 乱七八糟 无标签 暗影之夜
curl -XPUT "http://localhost:9200/graylog_*/_settings" -H 'Content-Type: applicatio : { "max_result_window" : 999999999 } }'

CentOS7.X OpenSSH OpenSSL 加固指南

0 条评论 乱七八糟 无标签 暗影之夜

本次撰写背景

  • 因操作系统过于老旧,部分用户使用的中间件可能依赖于过老的 OpenSSL组件,如果刻意升级较新OpenSSL可能会影响现有应用的正常运行

本次撰写的目的

  • 使新版本的OpenSSL 与系统现有版本共存
  • 只限升级后的OpenSSH使用升级过的OpenSSL 其他模块链接情况不受影响

升级步骤

  • 因CentOS7 官方源过期,现直接替换成阿里云的源,最小安装不包含wget软件包,请使用如下命令替换软件源:

    curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
    

编辑 CentOS-Base.repo,将无效的软件源链接清除

yum clean all
yum makecache
  • 加固前所需下载安装的软件包:

    zlib; zlib-devel;gcc; make; pam-devel;perl;openssl-devel;perl-CPAN

    当编译OpenSSL报错 “Can‘t locate IPC/Cmd.pm” 时 请使用以下方法

    yum install -y perl-CPAN
    #进入CPAN的shell模式
    perl -MCPAN -e shell
    
    # 首次进入需要配置shell,按照提示操作即可,我这里是一路回车。
    # 在shell中安装缺少的模块
    install IPC/Cmd.pm
    # 安装完成后输入exit 退出
    

    解压openssl tar.gz 包之后,到OpenSSL 目录下

    ./config --prefix=/usr/local/openssl3_for_ssh --openssldir=/etc/ssl --shared zlib
    make 
    make install
    # openssl3 为链接库目录 建议自定义,但不建议放到 /usr 或 /usr/bin  下 这类目录由发行版控制.
    # 可以放到 /usr/local 下 切记不要替换或覆盖原旧版本OpenSSL链接库
    echo "/usr/local/openssl3_for_ssh/lib64" >> /etc/ld.so.conf   //添加库路径关联 这一步和编译OpenSSH 相关
    ldconfig

    解压 openssh.tar.gz 包之后 到 OpenSSH目录下

    ./configure --prefix=/usr --sysconfdir=/etc/ssh  --with-zlib --with-ssl-dir=/usr/local/openssl3_for_ssh \
       --with-md5-passwords --with-pam --with-selinux --mandir=/usr/share/man
    make
    make install
    echo 'X11Forwarding yes' >> /etc/ssh/sshd_config
    echo "PermitRootLogin yes" >> /etc/ssh/sshd_config 
    cp -p contrib/redhat/sshd.init /etc/init.d/sshd
    chmod +x /etc/init.d/sshd
    chkconfig  --add  sshd
    chkconfig  sshd  on
    chkconfig  --list  sshd
    service sshd restart

  • 注意事项:

    可以选择 备份 /etc/pam.d

    可以选择 将 /etc/ssh/sshd_config 文件作为备份移动到其他目录

  • 如果提示:

/etc/ssh/sshd_config line 79: Unsupported option GSSAPIAuthentication
/etc/ssh/sshd_config line 80: Unsupported option GSSAPICleanupCredentials

可以选择到 sshd_config 中注释报错选项

  • 如果提示
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for '/etc/ssh/ssh_host_rsa_key' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Unable to load host key "/etc/ssh/ssh_host_rsa_key": bad permissions
Unable to load host key: /etc/ssh/ssh_host_rsa_key
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for '/etc/ssh/ssh_host_ecdsa_key' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Unable to load host key "/etc/ssh/ssh_host_ecdsa_key": bad permissions
Unable to load host key: /etc/ssh/ssh_host_ecdsa_key
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for '/etc/ssh/ssh_host_ed25519_key' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Unable to load host key "/etc/ssh/ssh_host_ed25519_key": bad permissions
Unable to load host key: /etc/ssh/ssh_host_ed25519_key
sshd: no hostkeys available -- exiting.
make: [check-config] Error 1 (ignored)

可以执行 chmod 600 /etc/ssh/ssh_host* 重新 make install

test

0 条评论 未分类 无标签 暗影之夜

test

欢迎使用emlog

0 条评论 未分类 无标签 暗影之夜

这是系统生成的演示文章。编辑或者删除它,然后开始您的创作吧!