存档

‘Linux’ 分类的存档

proxmox下lxc容器虚拟机centos8更新后dns失效问题解决

2021年10月6日 没有评论

从pve 6.3之后版本基本以后都会对接centos8以上的版本了。
今天下载更新centos8后。肯定yum update -y更新版本了。
可更新之后重启系统,发现yum不能了。还以为什么问题ping一下域名也是一样。查了很多原因。没办法应该是dns哪里有问题了。只能手动更新一下。
解决办法如下:

手工修改 /etc/resolv.conf

修改 /etc/NetworkManager/NetworkManager.conf 文件,在main部分添加 “dns=none” 选项:

1
2
3
[main]
#plugins=ifcfg-rh
dns=none

NetworkManager重载上面修改的配置,命令如下:

1
systemctl restart NetworkManager.service

手工修改 /etc/resolv.conf

1
2
nameserver 114.114.114.114
nameserver 8.8.8.8

然后重启一下系统看看是否存下来了。
/etc/resolv.conf重启后的文件如下:

1
2
3
4
# --- BEGIN PVE ---
search vps12.com
nameserver 114.114.114.114
# --- END PVE ---

linux登录windows服务器图形桌面

2021年10月3日 没有评论

安装rdesktop工具

sudo apt-get install rdesktop

启动rdesktop

rdesktop 192.168.1.2 -f #-f为全屏显示

退出rdesktop全屏

ctrl+alt+enter

自定义分辨率进入windows服务器

rdesktop 192.168.1.2 -g 1660*1550

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

Signature from server’s host key is invalid

2021年9月10日 没有评论

用putty连接ssh的华为交换机,提示Signature from server’s host key is invalid

这里需要把putty默认的connection>ssh>host keys里的RSA置顶

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

解决:no matching key exchange method found. Their offer: diffie-hellman-group1-sha1

2021年8月14日 没有评论

第一种方法,在当前用户的.ssh目录下新建config文件,如当前用户为root

vi ~/.ssh/config
Host *
KexAlgorithms +diffie-hellman-group1-sha1
此方法只对当前用户生效,使用其他用户是又会报错。

第二种方法,修改/etc/ssh/ssh_config文件,在最末尾加入即可。

KexAlgorithms +diffie-hellman-group1-sha1

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

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, 解决方案 标签: ,

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