首页 技术 正文
技术 2022年11月7日
0 收藏 741 点赞 923 浏览 3136 个字

服务器版本如下:

@kelWEB4:/etc# lsb_release -a
LSB Version:
:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID:RedHatEnterpriseServer
Description:Red Hat Enterprise Linux Server release 6.2 (Santiago)
Release:6.2
Codename:Santiago

服务器内核如下:

@kelWEB4:/etc# uname -a
Linux kelWEB4 2.6.32-220.el6.x86_64 #1 SMP Wed Nov 9 08:03:13 EST 2011 x86_64 x86_64 x86_64 GNU/Linux

1 ssh无法连接服务器

1.1查看日志message

vi /var/log/messages 在日志里可以看到内容如下:

May 18 03:40:20 kelWEB4 sshd[18527]: error: This private key will be ignored.
May 18 03:40:20 kelWEB4 sshd[18527]: error: bad permissions: ignore key: /etc/ssh/ssh_host_rsa_key
May 18 03:40:20 kelWEB4 sshd[18527]: error: Could not load host key: /etc/ssh/ssh_host_rsa_key
May 18 03:40:20 kelWEB4 sshd[18527]: error:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
May 18 03:40:20 kelWEB4 sshd[18527]: error:
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
May 18 03:40:20 kelWEB4 sshd[18527]: error:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
May 18 03:40:20 kelWEB4 sshd[18527]: error:
Permissions 0644 for '/etc/ssh/ssh_host_dsa_key' are too open.
May 18 03:40:20 kelWEB4 sshd[18527]: error: It is recommended that your private key files are NOT accessible by others

1.2解决方法

从日志中可以看到是相关的权限有问题,从而查看ssh的配置文件的相关权限:

正确的权限设置如下:

Ssh的配置文件目录在/etc/ssh/目录下

@kelWEB4:/etc/ssh# ll
total 164
-rw-------. 1 root root 125811 Sep 7 2011 moduli
-rw-r--r--. 1 root root 2047 Sep 7 2011 ssh_config
-rw------- 1 root root 3890 Dec 7 2012 sshd_config
-rw-r--r-- 1 root root 3871 Dec 7 2012 sshd_config.20121207
-rw-------. 1 root root 672 Jul 21 2012 ssh_host_dsa_key
-rw-r--r--. 1 root root 590 Jul 21 2012 ssh_host_dsa_key.pub
-rw-------. 1 root root 963 Jul 21 2012 ssh_host_key
-rw-r--r--. 1 root root 627 Jul 21 2012 ssh_host_key.pub
-rw-------. 1 root root 1675 Jul 21 2012 ssh_host_rsa_key
-rw-r--r--. 1 root root 382 Jul 21 2012 ssh_host_rsa_key.pub
@kelWEB4:/etc/ssh# ll -d /etc/ssh
drwxr-xr-x. 2 root root 4096 Dec 7 2012 /etc/ssh

大部分的权限为0600,如果此处权限设置错误,那么会导致ssh无法连接到服务器中

2 用户不能使用su来进行切换用户

2.1 查看日志secure

日志存放的为/var/log/secure,查看内容报错如下:

May 12 17:28:47 kelWEB4 su: PAM (su-l) illegal module type: minlen=8
May 12 17:28:47 kelWEB4 su: PAM pam_parse: expecting return value; [...minclass=2]
May 12 17:28:47 kelWEB4 su: PAM (su-l) no module name supplied
May 12 17:28:47 kelWEB4 su: PAM (su-l) illegal module type: minlen=8
May 12 17:28:47 kelWEB4 su: PAM pam_parse: expecting return value; [...minclass=2]
May 12 17:28:47 kelWEB4 su: PAM (su-l) no module name supplied
May 12 17:28:47 kelWEB4 su: PAM (su-l) illegal module type: minlen=8
May 12 17:28:47 kelWEB4 su: PAM pam_parse: expecting return value; [...minclass=2]
May 12 17:28:47 kelWEB4 su: PAM (su-l) no module name supplied
May 12 17:28:47 kelWEB4 su: PAM (su-l) illegal module type: minlen=8
May 12 17:28:47 kelWEB4 su: PAM pam_parse: expecting return value; [...minclass=2]
May 12 17:28:47 kelWEB4 su: PAM (su-l) no module name supplied

2.2 解决方法

查看配置文件中包含此关键字的文件,使用命令如下:

@kelWEB4:/etc# find ./* -name \* -type f -print|xargs grep "minlen"
./pam.d/system-auth-ac:password requisite pam_cracklib.so try_first_pass retry=3 type= minlen=8 minclass=2

可以发现文件为

@kelWEB4:/etc# ll -d /etc/pam.d/system-auth-ac
-rw-r--r-- 1 root root 958 May 23 11:41 /etc/pam.d/system-auth-ac

查看里面的配置,看此行是否存在换行的错误,如果存在换行,那么将必然报错,此服务器报错,是因为在type后进行了换行,从而导致了错误的发生。

3、 可能的报错

Ø  在非同网段远程连接的时候,显示是可以登录,但是Connection closed by foreignhost

Ø  在同网段远程连接的时候,显示connection reset bypeer

Ø  还有看到错误could not open session

Ø  注意检查是否开启22端口,使用

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,028
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,518
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,365
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,146
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,780
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,857