问题描述:

  今天早上一个同事反应一个问题,通过ssh登录一台测试机的时候,发现两个账号,都是普通账号,一个账号能够登录,

  另外一个账号无法登录.问他之前有做过什么变更吗,提到的就是之前有升级过openssh的版本,其他的没有做过什么.

问题处理:

尝试了以下的解决方法:

  • 1.首先以普通的用户登录,然后通过su切换到该用户是能够切换的
  • 2.修改了sshd_config配置文件中的AllowUser也没有用
  • 3.在远程主机上使用ssh -vvv的方法打出调试信息,也没有发现更有用的信息
  • 4.试图将pam.d中的login文件都注释掉,但是也没有解决问题.
  • 5.通过passwd -S查看账户的状态是正常的

最终解决方法:

1.在sshd_config中将日志级别开启为DEBUG模式

LogLevel DEBUG

2.重启sshd服务

3.然后通过远程登录,收集日志,发现有如下日志

Aug  1 12:32:03 4A-LF-w10 sshd[171843]: debug1: userauth-request for user oracle service ssh-connection method none [preauth]
Aug 1 12:32:03 4A-LF-w10 sshd[171843]: debug1: attempt 0 failures 0 [preauth]
Aug 1 12:32:03 4A-LF-w10 sshd[171843]: Account oracle has expired
Aug 1 12:32:03 4A-LF-w10 sshd[171843]: debug1: userauth_send_banner: sent [preauth]
Aug 1 12:32:03 4A-LF-w10 sshd[171515]: debug1: Forked child 171860.

备注:通过以上信息,显示oracle账户过期了,怎么可能,默认的账号不都是永不过期吗?

4.查看oracle的状态

[root@4A-LF-w10 ssh]# chage -l oracle
Last password change : Aug 01, 2018
Password expires : never
Password inactive : never
Account expires : Jan 20, 11761191 #这是什么鬼,默认不是never的吗,怎么是这个,年份的时间显示也是不对的啊.
Minimum number of days between password change : 6
Maximum number of days between password change : 99999
Number of days of warning before password expires : 30

5.手动将账号过期时间修改为一个月以后,然后进行ssh登录

[root@4A-LF-w10 ssh]# chage -E "2018-09-01" oracle
[root@4A-LF-w10 ssh]# chage -l oracle
Last password change : Aug 01, 2018
Password expires : never
Password inactive : never
Account expires : Sep 01, 2018
Minimum number of days between password change : 6
Maximum number of days between password change : 99999
Number of days of warning before password expires : 30

备注:发现修改为这样的账号过期时间之后,是能够登录的.所以,也就是这个时间导致的啊.那么我想要改为账号永不过期该怎么办呢

6.基于这个时间戳,bing搜了下,有如下文章.

文章地址:

https://bugzilla.redhat.com/show_bug.cgi?id=1183638

描述:

Description of problem:

Issue using chage command to remove Account expiration date. The year format in "Account expires" is wrong.

Version-Release number of selected component (if applicable):

shadow-utils-4.1.4.2-19.el6.x86_64       #查看我的版本,就是这个版本.

How reproducible:
This issue is reproducible with shadow-utils-4.1.4.2-19.el6.x86_64 package on RHEL-6.5 and RHEL-6.6. #操作系统的版本也是这样的. Steps to Reproduce: # chage -l friday
Last password change : Jan 19, 2015
Password expires : never
Password inactive : never
Account expires : never
Minimum number of days between password change : 0
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7 # chage -E -1 friday Actual results: # chage -l friday
Last password change : Jan 19, 2015
Password expires : never
Password inactive : never
Account expires : Jan 20, 11761191
Minimum number of days between password change : 0
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7 Expected results: # chage -l friday
Last password change : Jan 19, 2015
Password expires : never
Password inactive : never
Account expires : never
Minimum number of days between password change : 0
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7 Additional info: I have noted the entry "-2" is added in 8th column of "/etc/shadow" file. # grep friday /etc/shadow
friday:$6$dBs1aWNG$ahInXkaUiM20opsZCGuvjRcUedH3iGVG3Fv3LzfuhR.3qgHvBbgNyyFlhiT/HOo8XRC7ZieHkwCMTMUqHmZdA/:16454:0:99999:7::-2: The workaround for this is to manually edit the configuration file "/etc/shadow" and remove the entry "-2", it will reset the value for "Account expires" to default.

备注:通过以上的文章中的提示,就是说通过chage -E -1的方式修改账号永不过期的时候,在shadow-utils和redhat6.6中遇到了bug,所以时间戳会有问题.

7.修改这个问题的方法,比如将账号过期时间修改为30年后过期,或者修改/etc/shadow这个文件将-2去掉,修改掉-2之后

[root@4A-LF-w10 tmp]# cat /etc/shadow | grep oracle
oracle:$1$pWh44Lv.$NAdyWSH.ZcYzU6w1JmYVx1:17744:6:99999:30::: 原来:
oracle:$1$pWh44Lv.$NAdyWSH.ZcYzU6w1JmYVx1:17744:6:99999:30::-2:

修改之后,查看账号过期时间:

[root@4A-LF-w10 tmp]# chage -l oracle
Last password change : Aug 01, 2018
Password expires : never
Password inactive : never
Account expires : never
Minimum number of days between password change : 6
Maximum number of days between password change : 99999
Number of days of warning before password expires : 30

备注:同时也能够通过ssh登录了.

文档创建时间:2018年8月1日13:35:56

linux环境中,ssh登录报错,Permission denied, please try again.的更多相关文章

  1. IDEA中使用git报错Permission denied (publickey)

    最近在使用idea开发时,使用git拉取远程仓库的代码时,报错Permission denied (publickey),原因是因为ssh的密钥失效,必须得重新设置下ssh的密钥即可. 命令很简单,在 ...

  2. 【jvm】linux 调用 jmap 报错Permission denied

    linux 调用 jmap  报错Permission denied 解决方案: 分别对java安装目录,java的bin目录以及jmap命令设置权限 chmod jdk1..0_79 chmod b ...

  3. Visual Studio Code 使用 Git插件报错 - Permission denied (publickey)

    在使用GitHub的时候,为了避免每次输入用户名密码,都会使用SSH方式代替Https. 按网上教程,大多数使用SSH-KeyGen生成公私钥对,而后上传公钥至Github,并切换Repositori ...

  4. java sftp 报错 Permission denied (没有权限;拒绝访问)

    解决办法: 1.检查账号密码是否错误 2.检查freeSSHD是否是以管理员身份运行的 3.检查sftp路劲有没有配置错误,java通过sftp将图片文件传输到指定文件夹,如果这个文件夹在配置的当前目 ...

  5. eclipse 向HDFS中创建文件夹报错 permission denied

    环境:win7  eclipse    hadoop 1.1.2 当执行创建文件的的时候, 即: String Path = "hdfs://host2:9000"; FileSy ...

  6. ssh 登录报错 packet_write_wait: Connection to x.x.x.x port 22: Broken pipe

    问题 更新个人博客文章时遇到:Error: packet_write_wait: Connection to 192.30.253.113 port 22: Broken pipe packet_wr ...

  7. Eclipse/MyEclipse向HDFS中如创建文件夹等操作报错permission denied解决办法

    不多说,直接上干货! 问题现象 当执行创建文件的的时候, 即: String Path = "hdfs://host2:9000"; FileSystem fileSystem = ...

  8. linux下mysql登录报错“Access denied for user 'root'@'localhost' (using password: YES”)的处理方法

    最近登录某台服务器的mysql时候总报错: Access[root@log01 ~]# mysql -u root -p Enter password: ERROR 1045 (28000): Acc ...

  9. jenkins报错Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password) 的处理

    问题背景:jenkins服务器发布代码后需要执行删除缓存的操作ssh -p222 eus_pe_devadmin@1.1.1.1 "sudo rm -rf /dev/shm/nginx/hi ...

随机推荐

  1. 在Word 2007中添加参考文献及其引用的方法

    以前写文章的时候忽略了在文章中添加参考文献及其引用的方式,文章各式显得不太正式,在网上进行了相关搜索,将方法整理如下: 1.将光标停留在需要插入文献的地方[1],选择菜单栏上的"引用 -&g ...

  2. SecureCRT ,可是进入模拟器后TAB键还是无法补全

    SecureCRT是做网络,路由,交换机等设备的人都知道的工具 ,可是进入模拟器后TAB键还是无法补全,就很懊恼了. 设置步骤: 1)打开SecureCRT软件,选项—全局选项—常规—默认的会话设置— ...

  3. python获取上一个月第一天0点的unix时间戳

    这两天做统计,需要用到当月第一天0点0分0秒的unix timestamp,上个月第一天0点的unix时间戳,三个月前月第一天的0点的Unix时间戳,六个月前当月第一天的0点的Unix时间戳,现在整理 ...

  4. css限制显示字数,文字长度超出部分用省略号表示【转】

    为了保证页面的整洁美观,在很多的时候,我们常需要隐藏超出长度的文字.这在列表条目,题目,名称等地方常用到. (1).文字超出一行,省略超出部分,显示'...' 如果这种情况比较多,可以取一个切合作用的 ...

  5. hashMap 根据已有知识知道的

    public V put(K key, V value) { //假如table为空 if (table == EMPTY_TABLE) { inflateTable(threshold); } // ...

  6. ubuntu 安装bazel

    https://docs.bazel.build/versions/master/install-ubuntu.html#install-with-installer-ubuntu

  7. java-selenium下载百度图片

    package download; import java.io.DataInputStream; import java.io.File; import java.io.FileOutputStre ...

  8. (笔记)Linux下检测网卡与网线连接状态

    http://blog.chinaunix.net/space.php?uid=20357359&do=blog&cuid=1798479 Linux下检测网卡与网线连接状态,使用io ...

  9. 用OpenGL实现跳跃的立体小球

    一.目的 掌握OpenGL中显示列表对象的使用方法. 二.示例代码 Github地址 #include "stdafx.h" #include <GL/glut.h> ...

  10. Java如何以短格式显示月份?

    在Java中,如何显示短格式的月份名称? 使用DateFormatSymbols().DateFormatSymbols类的getShortMonths()方法,本示例显示了几个月的简写名称. pac ...