找回密码
 加入我们

QQ登录

只需一步,快速开始

搜索
查看: 3133|回复: 5

[软硬件讨论] openssh改密码认证后

[复制链接]
发表于 2010-10-6 19:08 | 显示全部楼层 |阅读模式
v版pre 1.45,装了openssh,以前老版本的openssh好像是默认密码登录的,现在要密匙,感觉没必要,又改回密码认证了
* V$ i& M2 v2 t& v7 i5 v: k: f& j
2 v4 |7 T- _1 ?: p- C配置文件sshd_config改了一下就可以了,但是遇到一个奇怪的问题,每次第一次连接,如果wifi没先激活就用winscp之类的ssh客户端连接,就会出现”不支持的验证方式“的错误,重启关机pre也没用,只有把resolv.conf的nameserver更新了才行,附上我的配置文件,不知道跟设置有关系吗
1 J& j* [4 r# N/ e& d+ J/ S1 e2 Z! J* b
#        $OpenBSD: sshd_config,v 1.80 2008/07/02 02:24:18 djm Exp $0 i+ T4 h- _% K" \9 m4 Q/ {
4 K4 S1 B& b% P( J
# This is the sshd server system-wide configuration file.  See* f! X; S6 `3 G( _
# sshd_config(5) for more information.
" i7 f8 _6 X  M; k# r9 Z' ]; s1 a9 c" X% ^
# This sshd was compiled with PATH=/opt/sbin:/opt/bin:/usr/sbin:/usr/bin:/sbin:/bin( O9 c4 E5 m) \0 W& T" ?. d
# X" b0 n+ V  O
# The strategy used for options in the default sshd_config shipped with; q( q, p6 e1 _9 e, w
# OpenSSH is to specify options with their default value where
- F. H  K2 p/ T1 p5 K8 E, M# i# possible, but leave them commented.  Uncommented options change a
7 D* ?# }! N7 I0 Q- H& S. v# default value.
. Z$ q' C8 @  L' O
# n0 N" R& r! t) q#Port 223 `2 B+ _  n- o0 x: l
#AddressFamily any
, r4 ]+ K" B( u1 h#ListenAddress 0.0.0.04 z" ~: i, [/ v( t! c
#ListenAddress ::
+ u3 F9 u0 [/ q# f1 S1 o
4 I9 {  b7 u5 n# Disable legacy (protocol version 1) support in the server for new9 @3 @0 @+ X. [
# installations. In future the default will change to require explicit/ T5 O9 H  i% x2 \( Z/ [
# activation of protocol 1
# S& ]1 F/ |3 Q+ I7 UProtocol 2. z0 ]# F" S; Q# s# Z
* i$ t$ _; b1 W; o* t7 V3 F
# HostKey for protocol version 1( g0 m, {+ b3 A7 O* A" Z! {0 O
#HostKey /opt/etc/openssh/ssh_host_key
& w1 T& q  h" L6 W) x4 {1 X0 w# HostKeys for protocol version 2
9 r& x- O- w- |2 u: k4 c! z; _' f#HostKey /opt/etc/openssh/ssh_host_rsa_key3 t4 U5 e- f# M' t1 n2 H
#HostKey /opt/etc/openssh/ssh_host_dsa_key8 {* e  }4 e. Q9 [0 @

, L5 Q/ _: Z" x0 T# Lifetime and size of ephemeral version 1 server key4 _5 Y8 z* W+ R. q' b
#KeyRegenerationInterval 1h3 {: p6 ^4 E- [% F# z6 e
#ServerKeyBits 1024
* R; C, s: N) l! A8 y& x9 W' B$ E' G/ F; G: X/ ]6 R# C5 s
# Logging% C1 P: y& P, w# v
# obsoletes QuietMode and FascistLogging6 H( `7 f; [1 W& f2 g
#SyslogFacility AUTH
9 C: J" h/ b. i# C) h  @  b2 o#LogLevel INFO4 s% n4 P; w1 z& ^7 J

. J/ g& a; o! g3 M  Z% a# Authentication:
! D; l; P( k1 q4 x/ ^1 i0 N" I: O" q3 [" S2 J
#LoginGraceTime 2m3 X6 b4 E( q6 [" l8 T
PermitRootLogin yes
1 T( T; R* `5 g- ^$ ?#StrictModes yes% [. b8 N& |( W8 M6 ~& E0 m
#MaxAuthTries 6
) R% b5 O* x  {( b5 z, g( T! r#MaxSessions 10
% m3 j9 [% z& \2 [
' A. A* [4 u0 T+ B6 u7 y4 D/ HRSAAuthentication no; W/ z" r0 t7 i& h! l. ?6 Y
PubkeyAuthentication no6 B% }, G) K! a% I& i3 e
#AuthorizedKeysFile        .ssh/authorized_keys
2 Y1 a7 h; v4 l" X2 R* l% |3 @3 u
" o( m5 E: z% q; f+ f, b# For this to work you will also need host keys in /opt/etc/openssh/ssh_known_hosts
7 ^" T) ^3 U$ I& R" g#RhostsRSAAuthentication no
; n  w# f; u! P/ B3 F# similar for protocol version 2# O9 _& p$ E/ _& G) M) p1 t
#HostbasedAuthentication no
- V' c' X% G" y* Z( q  O/ o# Change to yes if you don't trust ~/.ssh/known_hosts for+ \2 B; K9 n4 b$ x0 m% I
# RhostsRSAAuthentication and HostbasedAuthentication
+ c( ~* N. u7 s8 i#IgnoreUserKnownHosts no
- L* V0 H7 P  I+ v4 h) a5 n2 u) `# Don't read the user's ~/.rhosts and ~/.shosts files
1 J5 p/ ]) k2 y1 U3 q3 }6 m& X( A#IgnoreRhosts yes
$ ^* C5 T  _) c' e* |
% J7 ^+ a1 w, {  f# To disable tunneled clear text passwords, change to no here!
& U% I1 d0 Q. Y/ D# DPasswordAuthentication yes" ]- x, @% ]9 y$ \+ A1 S
PermitEmptyPasswords yes
2 P0 b, g0 W2 L. `  S4 d2 z: v$ A2 W2 d0 b* y( b+ f, U
# Change to no to disable s/key passwords3 n% |; t2 m  E7 B4 j# T
ChallengeResponseAuthentication yes
  \% v' \4 l  Q4 L. z3 d, I) ?5 Q: j& U
# Kerberos options
" v7 f+ R7 p8 n0 NKerberosAuthentication yes
  n1 ?7 j. E1 A% s4 l& s9 Y. v+ B#KerberosOrLocalPasswd yes( @: Z% |4 G* K, C8 X. O1 {- V6 S/ t
#KerberosTicketCleanup yes. w( \9 r0 Z+ C) `4 g) {
#KerberosGetAFSToken no
" ]: C3 q. k4 W) ]2 x9 `* s2 Y5 {% F2 `* n) Q1 q9 \  M
# GSSAPI options
0 ]5 }8 u. a: u5 F8 P#GSSAPIAuthentication no2 V6 T! ~) o7 d# R) Y
#GSSAPICleanupCredentials yes1 D1 s/ z% h- q) X! ]' Z

- G  K( J  U* L$ {- n# Set this to 'yes' to enable PAM authentication, account processing,
$ z6 H( ?. _+ f  p8 S# and session processing. If this is enabled, PAM authentication will 5 s5 O8 n# c9 K8 p
# be allowed through the ChallengeResponseAuthentication and; X  \/ d) K8 o
# PasswordAuthentication.  Depending on your PAM configuration,$ [) L, `1 z' c' Z& Z* P6 v- j! K
# PAM authentication via ChallengeResponseAuthentication may bypass8 s# G, n6 t1 a- ^  C1 O
# the setting of "PermitRootLogin without-password".
2 }+ W7 A4 ~+ n) E2 \% g# If you just want the PAM account and session checks to run without
+ |6 d5 {/ X1 B" I$ e: ^( M# PAM authentication, then enable this but set PasswordAuthentication! f# p8 P1 V" {5 J* E" E6 y1 C
# and ChallengeResponseAuthentication to 'no'.
( k; ~! k: C0 QUsePAM yes
: w; F/ }& p3 n; E1 k3 R! b: i
#AllowAgentForwarding yes
+ l% H3 j1 z! u. O; b  w# }# h4 [% z) ?#AllowTcpForwarding yes7 Y4 k+ `# {/ C1 g. z
#GatewayPorts no6 G3 ]4 E" s  D% [6 g
#X11Forwarding no  F$ i) {. g& s* v: j5 X; w
#X11DisplayOffset 10  R* t# k8 K/ G" V& A
#X11UseLocalhost yes
8 R9 k7 _; S6 x& ~# ~#PrintMotd yes7 q5 r& A4 v: W' Q  w6 J
#PrintLastLog yes# {  \6 R* q8 P% u7 A
#TCPKeepAlive yes' i/ c  e. ^4 ~
#UseLogin no2 H' |. u/ g. ^
#UsePrivilegeSeparation yes
. h5 z. s; F8 D8 N9 Q#PermitUserEnvironment no
, \& F5 q. |1 D! y" t! \; J#Compression delayed3 Q, _; D7 D3 Q0 g( w7 W: \* _
#ClientAliveInterval 0: t- q9 F/ F1 P# ~4 T% }* \# R
#ClientAliveCountMax 37 S7 x1 t: L8 ^
#UseDNS yes
- p* {) A" J$ v; M, j* }#PidFile /opt/var/run/sshd.pid( X" Y1 G" t  v$ ~- ]8 i
#MaxStartups 10
  `7 {  l3 G$ L. v4 b' l* x#PermitTunnel no
% X( c5 }% N( r) ?5 H* X* N#ChrootDirectory none* H- N3 x5 b) P: C0 N& C

- o, ]+ W& y8 E2 @2 [- ]0 U# no default banner path
5 S3 g6 K) s" B5 G4 c4 D#Banner none
, h, P: j7 B/ v( e" k5 k5 J& x
; H7 ]2 x* R+ g+ E6 w& W! j# override default of no subsystems6 u5 D' Y  X$ A* P+ C
Subsystem        sftp        /opt/libexec/sftp-server& `1 P' ~/ K9 G$ z8 s1 |8 p
- |( K) G. t- ?. P. s, y
# Example of overriding settings on a per-user basis
6 N; I8 ^5 Q- s4 a8 {) r#Match User anoncvs0 |! r8 C8 g3 n6 x
#        X11Forwarding no
, o$ [' }+ h' |) b) D+ Q, N#        AllowTcpForwarding no
' J6 l4 o% E, \8 L3 `8 X#        ForceCommand cvs server
回复

使用道具 举报

 楼主| 发表于 2010-10-7 00:19 | 显示全部楼层
感觉这个openssh不太稳定,有时候会验证失败,然后造成vpn都工作不正常了
回复 支持 反对

使用道具 举报

发表于 2010-10-8 10:01 | 显示全部楼层
俺的oppensh就从来没有连接上成功过,郁闷
回复 支持 反对

使用道具 举报

发表于 2010-10-8 10:07 | 显示全部楼层
这是我每次刷机后装ssh所用的配置文件,用wqi发到手机上,即可用密码登录.供参考
, w6 N/ a+ H4 p6 C  ~9 l
  R2 L8 T( l7 b7 \- @/opt/etc/openssh/sshd_config
  1. Port 22' z  d3 a$ `, h) q# O3 o& f
  2. Protocol 2
    4 T" `! E& b6 s: g& a
  3. PermitRootLogin yes
    ' @5 {# H/ q# j2 w6 O* n
  4. PasswordAuthentication yes, U+ t8 _# U+ J/ e" x8 J
  5. PermitEmptyPasswords no  L6 ?5 R+ Z" Q9 S6 a
  6. Subsystem        sftp        /opt/libexec/sftp-server
复制代码
/etc/event.d/mobi.optware.openssh
  1. description "OpenSSH Daemon"
    7 ~6 X7 {& Y( {. C: V

  2. ; E0 C8 ^. C2 G6 Z
  3. start on stopped finish
    1 V* z9 U8 \3 |- N, {
  4. stop on runlevel [!2]
    / r6 r7 I6 o, @& |" Q5 m

  5. ( u- ^* V" \; Y9 k  F  z$ e9 i- Z
  6. console none9 P& Z; G/ E. G2 j' o
  7. 2 ]# c( n  Y: ]3 V: g. w
  8. # Make sure SSH sessions don't slow down GUI use
    4 F- `" N" m! n: ~5 W
  9. nice 5
    ) v/ t4 D2 I6 C& M  o% A0 I) _
  10. + T5 d- s: t6 k' [. ~" V: i
  11. # Restart the SSH daemon if it exits/dies
    + H7 b6 r: ]; n  i0 B# l& I; \
  12. respawn
    * \# _( V* l9 W3 w9 d
  13. 1 P6 H) T  X- g' s
  14. # -D doesn't detach and become daemon) _+ G& C1 m$ t0 Y* B
  15. # -p sets the TCP port1 X8 E. E; s7 j( `0 d7 q+ l' Q
  16. # -o "PasswordAuthentication no" prohibits login using password
    ' U  J6 ?" F# ]- R
  17. # but allows login using ssh key based authentication (same behavior as -s in dropbear)
    . T3 ~6 A. i2 M1 y0 f& X; ]
  18. # -o "PermitRootLogin without-password" prohibits root login using password! w2 M2 _" D# W7 P
  19. # but allows root login using ssh key based authentication (same behavior as -g in dropbear)
    ' F* W0 I' g  J3 w$ X
  20. exec /opt/sbin/sshd -D, s' Q6 N# z, `9 R- ?& F; i' i

  21. ) }1 u. K7 h8 F
  22. pre-start script
    & f) H, m" ]/ E; r  {+ Z% s/ y& K
  23.      # Add firewall rule to allow SSH access over WiFi on port 229 h# H; c" G( C
  24.      # Remove the "-i eth0" on both of the following lines to enable SSH access
    % y- ~1 s* O( P- a6 k5 a
  25.      # over the cellular data network (EVDO, etc).4 _+ g( A" }# d( n  K
  26.      /usr/sbin/iptables -D INPUT -i eth0 -p tcp --dport 22 -j ACCEPT || /bin/true* W! B# j( P% r
  27.      /usr/sbin/iptables -I INPUT -i eth0 -p tcp --dport 22 -j ACCEPT
    9 D- J& d0 \: ^/ ^" k
  28. end script0 \1 Z. Q9 Y# i3 O" e- U* p

  29. ; l# g* C" d9 M$ G. a( H
  30. # end of file' c. y- O- R& A: N- d3 \
复制代码
) k# p  F6 K( a5 J& }' k  S
[ Edited by freezex on 2010-10-8 10:09 ]
回复 支持 反对

使用道具 举报

发表于 2010-10-9 16:46 | 显示全部楼层
俺的oppensh就从来没有连接上成功过,郁闷2
回复 支持 反对

使用道具 举报

头像被屏蔽
发表于 2011-4-2 03:26 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 加入我们

本版积分规则

QQ|Archiver|手机版|小黑屋|吹友吧 ( 京ICP备05078561号 )

GMT+8, 2025-3-10 11:43 , Processed in 0.247493 second(s), 15 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表