centos docker ssh 登录
使用ifconfig,需要安装net-tools。
yum install -y net-tools
安装openssl,openssh-server
yum install -y openssl openssh-server
/usr/sbin/sshd -D
sh-4.2# /usr/sbin/sshd -D
Could not load host key: /etc/ssh/ssh_host_rsa_key
Could not load host key: /etc/ssh/ssh_host_ecdsa_key
Could not load host key: /etc/ssh/ssh_host_ed25519_key
sshd: no hostkeys available -- exiting.
创建秘钥等
[root@master /]# cd
[root@master ~]# ssh-keygen -q -t rsa -b 2048 -f /etc/ssh/ssh_host_rsa_key -N ''
[root@master ~]# ssh-keygen -q -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N ''
[root@master ~]# ssh-keygen -t dsa -f /etc/ssh/ssh_host_ed25519_key -N ''
接着修改sshd_config文件配置信息,路径为 /etc/ssh/sshd_config
1.将 Port 22 前面的注释去掉
2.将 PermitRootLogin 的 no 改为 yes
重新启动sshd:命令结尾加个‘&’,自动后台运行,启动成功会返回进程号
[root@master ~]# /usr/sbin/sshd -D &
[root@master ~]# ps aux |grep sshd
root 50 0.0 0.0 112948 7756 pts/1 S 17:50 0:00 /usr/sbin/sshd -D
root 57 0.1 0.1 155552 10024 ? Ss 17:52 0:00 sshd: root@pts/2
root 73 0.0 0.0 9104 828 pts/1 S+ 17:53 0:00 grep --color=auto sshd
重新设置root密码等
yum install passwd
[root@master ~]# passwd
Changing password for user root.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
查看cenos版本
sh-4.2# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
sh-4.2# uname -a
Linux master 4.14.24-qnap #1 SMP Thu Jan 7 01:26:20 CST 2021 x86_64 x86_64 x86_64 GNU/Linux
mongo 安装
启动
mongod --config /usr/local/mongo/etc/mongodb.conf
或者使用
systemctl start mongodb.service
mongodb 位置:/usr/local/mongodb
mongodb 配置:mongod --config /usr/local/mongo/etc/mongodb.conf
dbpath=/usr/local/mongo/data/db # 指定数据存储目录
logpath=/usr/local/mongo/log/mongodb.log # 指定日志文件存储目录
logappend=true # 使用追加方式写日志
port=27017 # 端口
fork=true # 以守护进程方式运行
auth=true # 启用验证
bind_ip=0.0.0.0 # 允许任意外部地址访问
创建 mongodb.service
[Unit]
Description=mongodb
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/mongo/bin/mongod --config /usr/local/mongo/etc/mongodb.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/usr/local/mongo/bin/mongod --shutdown --config /usr/local/mongo/etc/mongodb.conf
PrivateTmp=true
[Install]
WantedBy=multi-user.target
#设置可执行权限
chmod 754 mongodb.service
**启动服务**
systemctl start mongodb.service
**关闭服务**
systemctl stop mongodb.service
**开机启动 **
systemctl enable mongodb.service
Centos7升级openssl到1.1.1版本
一、升级openssl操作方法
1.1安装telnet服务,避免升级openssl和openssh导致主机不能远程
1.2准备环境
yum install -y gcc gcc-c++ glibc make autoconf openssl openssl-devel pcre-devel pam-devel pam* zlib*
1.3下载openssl源码包,我这里下载的版本是openssl-1.1.1g
wget https://www.openssl.org/source/openssl-1.1.1g.tar.gz
1.4操作升级openssl
解压:tar xf openssl-1.1.1g.tar.gz
进入openssl目录:cd openssl-1.1.1g
编译安装:./config --prefix=/usr/local/openssl --openssldir=/etc/ssl --shared zlib
make -j4
make install
1.5备份当前的openssl
mv /usr/bin/openssl /usr/bin/openssl.bak
mv /usr/include/openssl /usr/include/openssl.bak
1.6配置使用新版本
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/openssl/include/openssl /usr/include/openssl
查看是否创建成功:ll /usr/bin/openssl;ll /usr/include/openssl
1.7更新动态链接库数据
echo “/usr/local/openssl/lib” >> /etc/ld.so.conf
1.8重新加载动态链接库
/sbin/ldconfig
1.9验证openssl版本
openssl version
解决openssl: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory错误
ln -s /usr/local/lib64/libssl.so.1.1 /usr/lib64/libssl.so.1.1
ln -s /usr/local/lib64/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1
参考
https://blog.csdn.net/weixin_45529004/article/details/107487645