免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 6432 | 回复: 4
打印 上一主题 下一主题

[系统管理] 为什么openssh6.6p1 不能获取ulimit 值 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2014-08-29 10:56 |只看该作者 |倒序浏览
请高手帮忙看下,是我设置问题还是软件问题。
因安全需要将openssh 升级到最新版,因设备较多,编译rpm安装会存在依赖关系,使用源码安装又觉得麻烦。当时使用的源码安装。现在遇到问题如下。

使用ssh 登录主机后,用户不能获取到ulimit 值。这里我设置了open files 为102400,但登录后值为1024.  su - 切换后可正常获取到设置的值。root也存在同样问题。

sshd_config默认,未配置。

以下是我测试的情况

  1. [moon@MOON ~]$ ulimit -n
  2. 102400
  3. [moon@MOON ~]$ exit
  4. logout
  5. You have new mail in /var/spool/mail/moon
  6. [moon@MOON ~]$ ssh 192.168.180.129
  7. moon@192.168.180.129's password:
  8. Last login: Fri Aug 29 10:30:51 2014 from 192.168.180.129
  9. [moon@MOON ~]$ ulimit -n
  10. 1024
  11. [moon@MOON ~]$ su - moon
  12. Password:
  13. [moon@MOON ~]$ ulimit -n
  14. 102400
  15. [moon@MOON ~]$ ssh 192.168.180.129
  16. moon@192.168.180.129's password:
  17. Last login: Fri Aug 29 10:44:18 2014 from 192.168.180.129
  18. [moon@MOON ~]$ ulimit -n
  19. 1024
  20. [moon@MOON ~]$ ssh -V
  21. OpenSSH_6.6p1, OpenSSL 1.0.0-fips 29 Mar 2010
  22. [moon@MOON ~]$ ssh 192.168.180.129 -l root
  23. root@192.168.180.129's password:
  24. Last login: Fri Aug 29 10:03:09 2014 from 192.168.180.129
  25. [root@MOON ~]# ulimit -n
  26. 1024
  27. [root@MOON ~]# su - root
  28. [root@MOON ~]# ulimit -n
  29. 102400
  30. [root@MOON ~]# service sshd restart
  31. starting /usr/local/openssh-6.6p1/sbin/sshd... \c
  32. done.
  33. [root@MOON ~]# ssh 192.168.180.129 -l moon
  34. no such identity: /root/.ssh/kdump_id_rsa: No such file or directory
  35. moon@192.168.180.129's password:
  36. Last login: Fri Aug 29 10:45:12 2014 from 192.168.180.129
  37. [moon@MOON ~]$ ulimit -n
  38. 102400
  39. [moon@MOON ~]$ exit
  40. logout
  41. Connection to 192.168.180.129 closed.
  42. [root@MOON ~]# ulimit -n
  43. 102400
  44. [root@MOON ~]# exit
  45. logout
  46. [root@MOON ~]# ulimit -n
  47. 1024
  48. [root@MOON ~]# service sshd restart
  49. starting /usr/local/openssh-6.6p1/sbin/sshd... \c
  50. done.
  51. [root@MOON ~]# ssh 192.168.180.129 -l moon
  52. no such identity: /root/.ssh/kdump_id_rsa: No such file or directory
  53. moon@192.168.180.129's password:
  54. Last login: Fri Aug 29 10:50:22 2014 from 192.168.180.129
  55. [moon@MOON ~]$ ulimit -n
  56. 1024
  57. [moon@MOON ~]$
复制代码
以下是sshd_config的配置
  1. [root@MOON ~]# cat /usr/local/openssh-6.6p1/etc/sshd_config
  2. #       $OpenBSD: sshd_config,v 1.93 2014/01/10 05:59:19 djm Exp $

  3. # This is the sshd server system-wide configuration file.  See
  4. # sshd_config(5) for more information.

  5. # This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

  6. # The strategy used for options in the default sshd_config shipped with
  7. # OpenSSH is to specify options with their default value where
  8. # possible, but leave them commented.  Uncommented options override the
  9. # default value.

  10. #Port 22
  11. #AddressFamily any
  12. #ListenAddress 0.0.0.0
  13. #ListenAddress ::

  14. # The default requires explicit activation of protocol 1
  15. #Protocol 2

  16. # HostKey for protocol version 1
  17. #HostKey /usr/local/etc/ssh_host_key
  18. # HostKeys for protocol version 2
  19. #HostKey /usr/local/etc/ssh_host_rsa_key
  20. #HostKey /usr/local/etc/ssh_host_dsa_key
  21. #HostKey /usr/local/etc/ssh_host_ecdsa_key
  22. #HostKey /usr/local/etc/ssh_host_ed25519_key

  23. # Lifetime and size of ephemeral version 1 server key
  24. #KeyRegenerationInterval 1h
  25. #ServerKeyBits 1024

  26. # Ciphers and keying
  27. #RekeyLimit default none

  28. # Logging
  29. # obsoletes QuietMode and FascistLogging
  30. #SyslogFacility AUTH
  31. #LogLevel INFO

  32. # Authentication:

  33. #LoginGraceTime 2m
  34. #PermitRootLogin yes
  35. #StrictModes yes
  36. #MaxAuthTries 6
  37. #MaxSessions 10

  38. #RSAAuthentication yes
  39. #PubkeyAuthentication yes

  40. # The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
  41. # but this is overridden so installations will only check .ssh/authorized_keys
  42. AuthorizedKeysFile      .ssh/authorized_keys

  43. #AuthorizedPrincipalsFile none

  44. #AuthorizedKeysCommand none
  45. #AuthorizedKeysCommandUser nobody

  46. # For this to work you will also need host keys in /usr/local/etc/ssh_known_hosts
  47. #RhostsRSAAuthentication no
  48. # similar for protocol version 2
  49. #HostbasedAuthentication no
  50. # Change to yes if you don't trust ~/.ssh/known_hosts for
  51. # RhostsRSAAuthentication and HostbasedAuthentication
  52. #IgnoreUserKnownHosts no
  53. # Don't read the user's ~/.rhosts and ~/.shosts files
  54. #IgnoreRhosts yes

  55. # To disable tunneled clear text passwords, change to no here!
  56. #PasswordAuthentication yes
  57. #PermitEmptyPasswords no

  58. # Change to no to disable s/key passwords
  59. #ChallengeResponseAuthentication yes

  60. # Kerberos options
  61. #KerberosAuthentication no
  62. #KerberosOrLocalPasswd yes
  63. #KerberosTicketCleanup yes
  64. #KerberosGetAFSToken no

  65. # GSSAPI options
  66. #GSSAPIAuthentication no
  67. #GSSAPICleanupCredentials yes

  68. # Set this to 'yes' to enable PAM authentication, account processing,
  69. # and session processing. If this is enabled, PAM authentication will
  70. # be allowed through the ChallengeResponseAuthentication and
  71. # PasswordAuthentication.  Depending on your PAM configuration,
  72. # PAM authentication via ChallengeResponseAuthentication may bypass
  73. # the setting of "PermitRootLogin without-password".
  74. # If you just want the PAM account and session checks to run without
  75. # PAM authentication, then enable this but set PasswordAuthentication
  76. # and ChallengeResponseAuthentication to 'no'.
  77. #UsePAM no

  78. #AllowAgentForwarding yes
  79. #AllowTcpForwarding yes
  80. #GatewayPorts no
  81. #X11Forwarding no
  82. #X11DisplayOffset 10
  83. #X11UseLocalhost yes
  84. #PermitTTY yes
  85. #PrintMotd yes
  86. #PrintLastLog yes
  87. #TCPKeepAlive yes
  88. #UseLogin no
  89. UsePrivilegeSeparation sandbox          # Default for new installations.
  90. #PermitUserEnvironment no
  91. #Compression delayed
  92. #ClientAliveInterval 0
  93. #ClientAliveCountMax 3
  94. #UseDNS yes
  95. #PidFile /var/run/sshd.pid
  96. #MaxStartups 10:30:100
  97. #PermitTunnel no
  98. #ChrootDirectory none
  99. #VersionAddendum none

  100. # no default banner path
  101. #Banner none

  102. # override default of no subsystems
  103. Subsystem       sftp    /usr/local/libexec/sftp-server

  104. # Example of overriding settings on a per-user basis
  105. #Match User anoncvs
  106. #       X11Forwarding no
  107. #       AllowTcpForwarding no
  108. #       PermitTTY no
  109. #       ForceCommand cvs server
  110. [root@MOON ~]#
复制代码

论坛徽章:
33
荣誉会员
日期:2011-11-23 16:44:17天秤座
日期:2014-08-26 16:18:20天秤座
日期:2014-08-29 10:12:18丑牛
日期:2014-08-29 16:06:45丑牛
日期:2014-09-03 10:28:58射手座
日期:2014-09-03 16:01:17寅虎
日期:2014-09-11 14:24:21天蝎座
日期:2014-09-17 08:33:55IT运维版块每日发帖之星
日期:2016-04-17 06:23:27操作系统版块每日发帖之星
日期:2016-04-18 06:20:00IT运维版块每日发帖之星
日期:2016-04-24 06:20:0015-16赛季CBA联赛之天津
日期:2016-05-06 12:46:59
2 [报告]
发表于 2014-08-29 11:08 |只看该作者
把 sshd_config 中的 UsePAM no 改成 UsePAM yes 就可以了.

论坛徽章:
0
3 [报告]
发表于 2014-08-29 11:13 |只看该作者
本帖最后由 dr12456 于 2014-08-29 11:14 编辑

回复 2# q1208c

刚测试了,不行呢。
  1. [root@MOON ~]# ulimit -n
  2. 1024
  3. [root@MOON ~]# service sshd restart
  4. starting /usr/local/openssh-6.6p1/sbin/sshd... \c
  5. /usr/local/openssh-6.6p1/etc/sshd_config line 97: Unsupported option UsePAM
  6. done.
  7. [root@MOON ~]# ssh 192.168.180.129
  8. no such identity: /root/.ssh/kdump_id_rsa: No such file or directory
  9. root@192.168.180.129's password:
  10. Last login: Fri Aug 29 11:11:11 2014 from 192.168.180.129
  11. [root@MOON ~]# ulimit -n
  12. 1024
  13. [root@MOON ~]# grep UsePAM /usr/local/openssh-6.6p1/etc/sshd_config
  14. UsePAM yes
  15. [root@MOON ~]#
复制代码

论坛徽章:
33
荣誉会员
日期:2011-11-23 16:44:17天秤座
日期:2014-08-26 16:18:20天秤座
日期:2014-08-29 10:12:18丑牛
日期:2014-08-29 16:06:45丑牛
日期:2014-09-03 10:28:58射手座
日期:2014-09-03 16:01:17寅虎
日期:2014-09-11 14:24:21天蝎座
日期:2014-09-17 08:33:55IT运维版块每日发帖之星
日期:2016-04-17 06:23:27操作系统版块每日发帖之星
日期:2016-04-18 06:20:00IT运维版块每日发帖之星
日期:2016-04-24 06:20:0015-16赛季CBA联赛之天津
日期:2016-05-06 12:46:59
4 [报告]
发表于 2014-08-29 11:53 |只看该作者
回复 3# dr12456
  1. /usr/local/openssh-6.6p1/etc/sshd_config line 97: Unsupported option UsePAM
复制代码
这行提示, 说明它不支持 PAM, Sorry.
   

论坛徽章:
0
5 [报告]
发表于 2015-05-04 13:13 |只看该作者
上面那个问题解决了。要在./configure时候加选项 with-pam=enable
如果是现在的6.8就不存在这个问题。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP