运维部落

香港vps促销1G99元 点击购买 美国vps促销512M59元 点击购买 日本vps促销1G100元 点击购买

centos7 升级openssh到openssh-8.6p1版本(转)

2021年8月3日 没有评论

时不时这个ssh都会暴一些这漏洞那漏洞好烦。今天给出centos7一个快速升级ssh8.6的脚本。转网上大牛,亲测,有效。

运行之前,查一下目前版本:

1
2
[root@localhost ~]# ssh -V
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 2017

把如下shell脚本添加到文件中,之后运行

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/bash
 
if [ ! -d /home/data ];then
      mkdir /home/data
fi
cd /home/data
yum update -y
yum install wget -y
 
wget -O openssh-8.6p1.tar.gz https://ftp.riken.jp/pub/OpenBSD/OpenSSH/portable/openssh-8.6p1.tar.gz
wget -O zlib-1.2.11.tar.gz https://zlib.net/zlib-1.2.11.tar.gz
wget -O openssl-1.1.1j.tar.gz https://www.openssl.org/source/openssl-1.1.1j.tar.gz
######保证下载的文件在/home/data里,且文件名相同
tar -zxf openssl-1.1.1j.tar.gz
tar -zxf zlib-1.2.11.tar.gz
tar -zxf openssh-8.6p1.tar.gz
chown -R root:root /home/data
#######################0end----------############################
 
##1---配置Telnet,以防SSH配置过程中出现问题,可以使用Telnet登录----
setenforce 0                      
#关闭selinux
systemctl stop firewalld         
#关闭
systemctl disable firewalld
 
yum install telnet telnet-server xinetd -y
#vi /etc/xinetd.conf                   
#修改disabled = no  ,即可以使用telnet服务
cp /etc/xinetd.conf   /home/data/xinetd.comfbk
sed -i '14a      disabled = no ' /etc/xinetd.conf          
#在第14行增加 disabled = no
echo -e 'pts/0\npts/1\npts/2\npts/3'  >>/etc/securetty
 
systemctl start telnet.socket  #开启服务
systemctl start xinetd        #开启服务
systemctl enable telnet.socket   #开机自起服务
systemctl enable xinetd
##1end---------------------------------------------------------------
 
##2 升级 OpenZlib-----------------------------------------
 
yum install  -y gcc gcc-c++ glibc make autoconf openssl openssl-devel pcre-devel  pam-devel
yum install  -y pam* zlib*
 
 
cd /home/data/zlib-1.2.11/
./configure --prefix=/usr/local/zlib
make && make install
##2end---------------------
 
##3升级openssl-------------
cd /home/data/openssl-1.1.1j/
./config --prefix=/usr/local/openssl -d shared
make && make install 
echo '/usr/local/openssl/lib' >> /etc/ld.so.conf
ldconfig
mv /usr/bin/openssl /home/data/opensslbk
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
 
##3end--and start update SSH------------------------
 
##4-----安装OpenSSH 8.6p1-------
cd /home/data/openssh-8.6p1/
./configure --prefix=/usr/local/openssh --with-ssl-dir=/usr/local/openssl --with-zlib=/usr/local/zlib
 make && make install
 
mv /etc/ssh/sshd_config /home/data/sshd_config.bak
cp /usr/local/openssh/etc/sshd_config /etc/ssh/sshd_config
mv /usr/sbin/sshd /home/data/sshd.bak
cp /usr/local/openssh/sbin/sshd /usr/sbin/sshd
mv /usr/bin/ssh /home/data/ssh.bak
cp /usr/local/openssh/bin/ssh /usr/bin/ssh
mv /usr/bin/ssh-keygen /home/data/ssh-keygen.bak
cp /usr/local/openssh/bin/ssh-keygen /usr/bin/ssh-keygen
mv /etc/ssh/ssh_host_ecdsa_key.pub /home/data/ssh_host_ecdsa_key.pub.bak
cp /usr/local/openssh/etc/ssh_host_ecdsa_key.pub /etc/ssh/ssh_host_ecdsa_key.pub
 
for  i   in  $(rpm  -qa  |grep  openssh);do  rpm  -e  $i  --nodeps ;done
 
#mv /etc/ssh/ssh_config.rpmsave /etc/ssh/ssh_config
mv /etc/ssh/sshd_config.rpmsave /etc/ssh/sshd_config
 
 
cp /home/data/openssh-8.6p1/contrib/redhat/sshd.init /etc/init.d/sshd
chmod u+x   /etc/init.d/sshd
#-------------修改配置文件------------
cp /etc/init.d/sshd /home/data/sshdnewbk
sed -i '/SSHD=/c\SSHD=\/usr\/local\/openssh\/sbin\/sshd'  /etc/init.d/sshd
sed -i '/\/usr\/bin\/ssh-keygen/c\         \/usr\/local\/openssh\/bin\/ssh-keygen -A'  /etc/init.d/sshd
sed -i '/ssh_host_rsa_key.pub/i\                \/sbin\/restorecon \/etc\/ssh\/ssh_host_key.pub'  /etc/init.d/sshd  
sed -i '/$SSHD $OPTIONS && success || failure/i\       \ OPTIONS="-f /etc/ssh/sshd_config"' /etc/rc.d/init.d/sshd
#---------操作sshd_config-------
sed -i '/PasswordAuthentication/c\PasswordAuthentication yes' /etc/ssh/sshd_config
sed -i '/X11Forwarding/c\X11Forwarding yes' /etc/ssh/sshd_config
sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
 
cp -arp /usr/local/openssh/bin/* /usr/bin/
service sshd restart
 
##3end------------------------------------------
 
 
#----------配置开机项---------------
chkconfig --add sshd
chkconfig --level 2345 sshd on
chkconfig --list
#----------关闭Telnet服务--------------- 
systemctl stop telnet.socket  
systemctl stop xinetd
systemctl disable xinetd.service
systemctl disable telnet.socket
 
#--------清理安装过程文件---------------------
rm -fr /home/data

运行完成后,运行一下ssh -V查一下是否最新版本。

1
2
[root@localhost ~]# ssh -V
OpenSSH_8.6p1, OpenSSL 1.1.1j  16 Feb 2021
分类: Linux, 网络产品 标签: , ,

centos java环境安装

2021年7月10日 没有评论

比较容易的就一条命令

1
yum install -y java-1.8.0-openjdk.x86_64

ps:
docker 安装java

1
docker pull java
分类: Linux 标签: ,

自建用于bzz的geth(swap-endpoint)RPC(linux、windows详细部署步骤)

2021年6月7日 没有评论

最近由于以太坊很火,很多朋友需求自己架设自己的rpc服务。这里给出两个方案,一个是linux一个是win的。

初自建geth(endpoint)用于保证Swarm挖矿持续不中断为了更好的服务自己。为什么自建RPC?
自建geth的好处:
1、不受官方服务器限制、保证多节点24*7连接性;
2、自建geth没有任何限制,可以多节点共用一台;
3、bee0.6.x以上版本连接请求过快,官方免费rpc满足不了。

Linux推荐使用系统:Ubuntu18.04(centos要下载软件部署)
安装git

1
2
3
4
apt-get install software-properties-common -y
sudo add-apt-repository ppa:git-core/ppa -y
sudo apt-get update -y
sudo apt-get install git -y

查看是否安装成功

1
git --version

有显示版本号就是安装成功。
安装geth

1
2
3
4
sudo apt-get install software-properties-common -y
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt-get update -y
sudo apt-get install ethereum -y

查看geth是否安装成功

1
geth --help

有信息反馈就是OK
安装screen让rpc在screen里面运行

1
apt-get install screen -y

创建一个叫geth的screen

1
screen -S geth

在screen里面运行启动命令

1
geth --cache=2048 --goerli --rpc --rpcaddr 0.0.0.0 --rpcport=8545 --rpcvhosts=* --rpcapi='eth,net,rpc'

等着他同步完成就可以了。
查看

1
screen -r geth

同步中的状态

Linux centos7/8
1. 下载go-ethereum

1
wget https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.10.3-991384a7.tar.gz

2. 解压 go-ethereum

1
tar -zxvf geth-linux-amd64-1.10.3-991384a7.tar.gz

3. 安装 go-ethereum

1
cp geth-linux-amd64-1.10.3-991384a7/geth /usr/bin/

三、运行go-ethereum

1. 启动一个名为geth的后台

1
screen -R geth

输入上面的命令后,按两次回车会新建一个后台。

2. 查看本机本地ip

1
ip address

3. 运行go-ethereum

1
geth --goerli --http --http.addr=1.1.1.1 --datadir /home/gethdata

#1.1.1.1换成自己ip
#–datadir /www/gethdata 指定存文件目录

注意: ip 需要使用第二步取得的ip取代

Ctrl+a+d退出 这玩意显示有点毛病

4. 检测go-ethereum 是否成功安装

1
lsof -i:8545

如果输出不为空,类似下图:

你已成功安装自己的go-ethereum 节点!不过还需要几个小时来等待它同步区块。

四、使用go-ethereum

在swarm节点上,更改配置文件的swap-endpoint字段:

swap-endpoint: http://1.1.1.1:8545 (1.1.1.1换成自己ip)
在你的SwarmBee的yaml配置文件里面修改好然后保存重启bee即可
如果你的Geth未同步完区块高度的话,则Bee会在Geth同步完后开始工作。

windows安装2012/2016/2019
这个就容易的多。直接去主网上下载。https://geth.ethereum.org/downloads/

1.下载https://geth.ethereum.org/downloads/
2.双击安装
3.geth.exe –goerli –http –http.addr=1.1.1.1 –datadir d:\gethdata
(自己建立一个放文件的gethdata)这个步骤不说明了。

利用Figlet工具创建酷炫VPS登入欢迎界面(转)

2021年5月3日 没有评论

有些时候我们在购买一些商家VPS服务器登入SSH后会看到商家自定义的欢迎界面,看着还感觉有点酷炫效果的。如果我们在自己管理和玩转的VPS、服务器中希望自定义比较个性的登入欢迎界面,可以利用Figlet工具进行设置,给我们闲暇且无聊的折腾过程一点点乐趣。

第一、Figlet工具的安装

wget ftp://ftp.figlet.org/pub/figlet/program/unix/figlet-2.2.5.tar.gz
cp figlet-2.2.5.tar.gz /usr/local/src/
cd /usr/local/src/
tar -zxvf figlet-2.2.5.tar.gz
cd figlet*
make figlet

因为我们需要生成需要的特定字符,所以需要在当前服务器中安装Figlet,默认没有安装包的,其实如果我们也只要在一台环境中安装,然后需要什么字符只要复制到需要的服务器中,并不需要所有都安装。同样的,我们也可以利用此生成的字符用到脚本运行的开始起头部分,用ECHO分行标注就可以。

这里需要补充一点,我们可能没有安装GCC,所以在执行make安装的时候会提示有”make: gcc: Command not found”错误,这里我们需要执行:

yum -y install gcc automake autoconf libtool make

常用的组件包。

Figlet工具的安装

如果没有错误,则会看到下面的成功安装界面。

Figlet工具的安装

第二、Figlet工具生成字符

./figlet LAOZUO.ORG -f fonts/standard.flf

这里我们需要用Figlet生成需要的字符,然后才可以用到我们的开机还原界面中。根据上述的脚本,换成我们自己的字符。以及我们可以用其他的字体。

字体:http://www.figlet.org/fontdb.cgi

Figlet工具生成字符

这里我用了一个3-d.flf字体的效果。具体我们可以根据不同的字体看看效果。这里老左就不多说了。

第三、添加登入欢迎界面

1、复制我们上面的字符

2、vi /etc/ssh/ssh-banner

添加到ssh-banner中。

3、设定Banner none

vi /etc/ssh/sshd_config

找到#Banner none一行,然后添加:

Banner /etc/ssh/ssh-banner

设定Banner none

然后保存退出。

4、重启SSH

/etc/init.d/sshd restart

最后,我们再退出当前SSH,然后重新登入。就可以看到这篇文章第一个图片的效果。Figlet生成字符然后添加登入界面完全是自己的折腾,看着登入界面和别人不同而已。

解决yum 出错:error: rpmdb: BDB0113 Thread/process 8173/139681223043136 failed: BDB1507

2021年4月6日 没有评论

s使用Ctrl+c 或者 Ctrl + z 或者 kill 或者其他原因 结束掉了yum进程,当再次执行yum的相关操作时报错:
错误:rpmdb: BDB0113 Thread/process 15381/140029102753600 failed: BDB1507 Thread died in Berkeley DB library
错误:db5 错误(-30973) 来自 dbenv->failchk:BDB0087 DB_RUNRECOVERY: Fatal error, run database recovery
错误:无法使用 db5 – (-30973) 打开 Packages 索引
错误:无法从 /var/lib/rpm 打开软件包数据库
CRITICAL:yum.main:

Error: rpmdb open failed

原因:rpm数据库在强制结束yum进程时被破坏了
解决办法:重新构建即可,步骤如下:
1、cd /var/lib/rpm
2、rm __db.* -rf #删除所有rpm库
3、rpm –rebuilddb #rpm的重新构建命令
4、yum clean all #用yum clean all清除
5、yum grouplist #用yum grouplist 命令测试yum,并进行相关更新

分类: Linux, 解决方案 标签: ,

win2008R2 sp1 update 错误80072EFE

2021年3月7日 没有评论

如果在检查更新时收bai到 Windows Update 错误 80072efe 或 80072f76,可能是因为计算机与 Windows Update 服务器之间的连接中断引起的。关闭 Windows Update,等待 10 到 15 分钟,然后再次运行 Windows Update。您也可以等待 Windows 自动更新在在其下一次计划时间时运行。 如果仍接收到这些错误之一,则可以运行自动疑难解答程序,该程序可以解决有关 Windows Update 的一些常见问题。 单击以下按钮: 解决此问题 在“文件下载”对话框中,单击“运行”,然后按照向导中的步骤进行操作。下载地址:

https://docs.microsoft.com/zh-cn/troubleshoot/windows-client/deployment/update-windows-update-agent#automatically-download-windows-update-agent

原始产品版本: Windows 10 – 所有版本,Windows Server 2012
原始 KB 编号: 949104

命令行程序哈希值查询方法(适用于Win8及以上系统)

2021年3月4日 没有评论

【哈希值查询方法(适用于Win8及以上系统)】
在命令提示符中输入:
certutil -hashfile “在此输入文件路径” SHA256
certutil -hashfile “在此输入文件路径” SHA1
certutil -hashfile “在此输入文件路径” MD5

IIS7/8如何实现访问HTTP跳转到HTTPS访问

2021年2月7日 没有评论

在URL中新建规则

1.新建一个空白规则,让http的访问跳转到https上

2.起一个名字例如HTTP to HTTPS redirect

3.在操作条件设置中选择重定向:https://{HTTP_HOST}/{R:1}
重定向类型:已找到(302) 或 参阅其它(303) 注:默认301也是可以的。

ps:
排除问题,今天,安装完iis重写后,设定强制301从http跳转https时出现进程池自动死的问题。其实是版本不同。访问出现:

Service Unavailable
HTTP Error 503. The service is unavailable.

看了日志后发现以下问题提示: C:\WINDOWS\system32\inetsrv\rewrite.dll 未能加载。返回的数据为错误。
先全部删除重写组件和web平台组件服务。然后重新下载安装即可。

解决:
不要用Web平台组件去下载URL重写工具, 自己手动下载, Url Rewrite 2.0 https://www.microsoft.com/zh-cn/download/details.aspx?id=7435
IIS7和IIS8的依旧可以用。

分类: 网络产品, 解决方案 标签:

linux centos7清除系统日志历史记录登录信息

2021年2月1日 没有评论

平时不管是web还是系统产生的日志都可能导致洗盘爆满,所以我在这里分享一些基本常用清理linux日志的方法。

# echo > /var/log/wtmp //清除用户登录记录
# echo > /var/log/btmp //清除尝试登录记录
# echo>/var/log/lastlog //清除最近登录信息
# echo > /var/log/secure //登录信息
# echo > /var/log/messages
# echo>/var/log/syslog //记录系统日志的服务
# echo>/var/log/xferlog
# echo>/var/log/auth.log
# echo>/var/log/user.log
# cat /dev/null > /var/adm/sylog
# cat /dev/null > /var/log/maillog
# cat /dev/null > /var/log/openwebmail.log
# cat /dev/null > /var/log/mail.info
# echo>/var/run/utmp
清除操作过的命令记录

# echo > .bash_history //清除保存的用户操作历史记录
# history -cw //清除所有历史

Linux查看History记录加时间戳小技巧
熟悉bash的都一定知道使用history可以输出你曾经输入过的历史命令,例如
[root@servyou_web ~]# history | more
./test.sh
vim test.sh
./test.sh
但是这里只显示了命令,并没有显示执行命令的时间,因为保存历史命令的~/.bash_history里并没有保存时间。

通过设置环境变量 export HISTTIMEFORMAT=”%F %T whoami ” 给history加上时间戳

[root@servyou_web ~]# export HISTTIMEFORMAT=”%F %T whoami ”
[root@servyou_web ~]# history | tail
2011-06-22 19:17:29 root 15 2011-06-22 19:13:02 root ./test.sh
2011-06-22 19:17:29 root 16 2011-06-22 19:13:02 root vim test.sh
2011-06-22 19:17:29 root 17 2011-06-22 19:13:02 root ./test.sh
2011-06-22 19:17:29 root 18 2011-06-22 19:13:02 root vim test.sh
2011-06-22 19:17:29 root 19 2011-06-22 19:13:02 root ./test.sh
2011-06-22 19:17:29 root 20 2011-06-22 19:13:02 root vim test.sh
2011-06-22 19:17:29 root 21 2011-06-22 19:13:02 root ./test.sh
2011-06-22 19:17:29 root 22 2011-06-22 19:13:02 root vim test.sh
2011-06-22 19:25:22 root 22 2011-06-22 19:13:02 root vim test.sh
2011-06-22 19:25:28 root history | tail

可以看到,历史命令的时间戳已经加上了,但是.bash_history里并没有加上这个时间戳。其实这个时间记录是保存在当前shell进程内存里的,如果你logout并且重新登录的话会发现你上次登录时执行的那些命令的时间戳都为同一个值,即当时logout时的时间。

尽管如此,对于加上screen的bash来说,这个时间戳仍然可以长时间有效的,毕竟只要你的server不重启,screen就不会退出,因而这些时间就能长时间保留。你也可以使用echo ‘export HISTTIMEFORMAT=”%F %T whoami “‘ >> /etc/profile 然后source一下就OK

例二: vi /root/.bash_history

例三:

 1、修改/etc/profile将HISTSIZE=1000改成0或1

  清除用户home路径下。bash_history

  2、立即清空里的history当前历史命令的记录

  history -c

  3、bash执行命令时不是马上把命令名称写入history文件的,而是存放在内部的buffer中,等bash退出时会一并写入。

  不过,可以调用’history -w’命令要求bash立即更新history文件。

  history -w

如何将CentOS 7升级到CentOS 8

2021年1月9日 没有评论

在本文中,您将学习如何将CentOS 7升级到CentOS 8。本文描述的步骤尚未描述正式升级,因此不能应用于生产服务器。
Upgrade-CentOS-7-to-CentOS-8

步骤1:安装EPEL储存库

首先,通过运行以下命令安装EPL存储库

yum install epel-release -y

在CentOS 7中安装EPEL Repo

步骤2:安装yum-utils工具

成功安装EPEL之后,通过运行以下命令来安装yum-utils。

然后,您需要通过执行命令来解析RPM软件包。

yum install rpmconf
rpmconf -a

保留默认RPM设置

接下来,清理所有不需要的软件包。

package-cleanup –leaves
package-cleanup –orphans

清理RPM软件包

步骤3:在CentOS 7中安装dnf

现在安装dnf软件包管理器,它是CentOS 8的默认软件包管理器。

yum install dnf

在CentOS 7中安装dnf

您还需要使用以下命令删除yum软件包管理器。

dnf -y remove yum yum-metadata-parser
rm -Rf /etc/yum

在CentOS 7中删除Yum

步骤4:将CentOS 7升级到CentOS 8

dnf upgrade

升级CentOS 7

接下来,如下所示使用dnf安装CentOS 8发行包。这需要一段时间。

dnf -y upgrade http://mirror.bytemark.co.uk/centos/8/BaseOS/x86_64/os/Packages/centos-release-8.0-0.1905.0.9.el8.x86_64.rpm

安装CentOS 8版本

接下来,升级EPEL存储库。

dnf -y upgrade https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

升级EPEL存储库

成功升级EPEL存储库后,请删除所有临时文件。

dnf clean all
使用nodeps参数删除CentOS 7的旧内核。

rpm -e `rpm -q kernel` –nodeps
接下来,请确保删除有冲突的软件包。

rpm -e –nodeps sysvinit-tools
此后,启动CentOS 8系统升级,如下所示。

dnf -y –releasever=8 –allowerasing –setopt=deltarpm=false distro-sync

CentOS 8系统升级

如果升级发现有报错,需要卸载from package后面的报名:

rpm -e –nodeps sysvinit-tools-2.88-14.dsf.el7.x86_64
rpm -e –nodeps python-inotify-0.9.4-4.el7.noarch
rpm -e –nodeps adwaita-qt5-1.0-1.el7.x86_64
rpm -e –nodeps pycairo-1.8.10-8.el7.x86_64
然后再次执行升级,此步骤需要等待较长时间。

dnf -y –releasever=8 –allowerasing –setopt=deltarpm=false distro-sync
步骤5:为CentOS 8安装新内核

要为CentOS 8安装新的内核,请运行命令。

dnf -y install kernel-core

在CentOS 8中安装内核

最后,安装CentOS 8最小软件包。

dnf -y groupupdate “Core” “Minimal Install”
现在,您可以通过以下命令运行检查安装的CentOS版本。

cat /etc/redhat-release
检查CentOS版本

升级完系统,记得重启,以上是将CentOS 7升级到CentOS 8的步骤,升级之前请做好数据备份,升级会造成一部分应用被卸载;大家可以学习借鉴之,还有其他的升级方法。