52AV璈A|52AV.ONE

 曉撖蝣
 蝡唾酉
敹急瑕
  • av隢憯BBS
  • 璈A
  • 芣瑟憭瘚
  • 鞎澆
  • 52av鋆貉摰
  • 銝剜-銝剖銝餅
     
亦: 3264|敺: 0
銝銝銝駁 銝銝銝駁

[ssh] 靽格 sshd 閮剖 ,閮剖瑼 /etc/ssh/sshd_config

[銴鋆賡包
頝唾唳摰璅撅
璅銝
潸” 2015-12-28 10:28:36 | 芰閰脖 撣 |摨閬 |梯璅∪
vi /etc/ssh/sshd_config , L( _! p+ y7 n

2 }4 X) {" V1 T3 d( ~1.靽格寥閮 port (舐典銵憭 port)
$ ~% P. h8 f5 p! s1 n9 E5 R/ pPort <port>7 G0 h) L" H3 X/ B3 i+ b2 X5 V

. L5 @% d% |1 H2.賜孵 ip (拍冽澆蝬脣/憭 IP 敶). m" l3 m3 I. v# [
ListenAddress 192.168.1.10+ G0 D! W* s. r/ b. ]

, x& X8 f. Q" {2 }4 {3.蝳甇 root 餃; {0 v2 H" Q2 g9 B$ K' Y8 G
PermitRootLogin no' g1 \$ ?6 I$ {3 O( B
蝞∠敹隞亙鈭箏董餃伐 su root嚗拍 sudo 撌乩- K9 c3 W3 q1 l: p& y

! \# X( [- u1 f3 f& y4.蝳甇V蝙函征撖蝣潛餃% G) r6 n+ g( N6 a
PermitEmptyPasswords no  J) y; E" y' e7 w

6 y) [4 Y$ a9 [& f- \5.閮望蝯孵撣唾蝢斤餃
5 S5 k6 n! k9 @! ~  ]/ t! |) tAllowUsers <user1> <user2> <user3>
/ E+ W0 R  q; ZAllowGroups <group>8 F3 _0 b; r3 h; M- b- m7 z* l8 H
DenyUsers *
7 p- q1 c3 G+ [% VDenyGroups no-ssh
" [5 l* r1 ]! W3 v0 a# j+ _寞撖阡嚗撠澆銝撣唾閮嚗憒 Allow 頝 Deny 閰梧蝯 Deny ! Y- k/ h  C8 n1 K, G9 ~& g
  M% q/ \+ \3 y; W" a8 h
6.撱a文蝣潛駁嚗撘瑁翰雿輻 RSA/DSA 撽霅7 O; A* A. a* S; Y6 r
RSAAuthentication yes
; V2 \3 }) J# G6 hPubkeyAuthentication yes
; o" ^5 W" t1 [) `5 ]) GAuthorizedKeysFile %h/.ssh/authorized_keys
! I" ~7 {, `$ ?- t: U0 o! UPasswordAuthentication no8 o8 h5 o$ t* H$ v' r& |; b& E
銝衣Ⅱ靽 user ~/.ssh 甈 700嚗撠閰 user public key 亙 ~/.ssh/authorized_keys 銝准Public key Y孵舀撠 ssh-keygen. h7 N# U$ V/ @6 B1 y; @
6 q: G. N+ ]2 \: v
7.閮 SSHv2% N1 y5 Z! @/ a$ J1 K* F$ W
Protocol 2
& l' |( F+ k. X. e. p1 y& ?( C% A% {0 u$ G  m" V$ v$ b7 R: B
8.嗥孵雿輻刻蝢斤銝餅雿餃亥綽鋆∩誑 somebody handsomebody 銝臭蝙典蝣潛餃亦箔
# Z+ D: ~2 g: B. j5 s5 q' B& FMatch User somebody,handsomebody
. e6 P! d- s" {2 q  GPasswordAuthentication no雿輻 TCP wrappers 嗡皞 IP
( Y: C2 Q+ d9 j& ^' y# R% z$ y  M/ H# vim /etc/hosts.deny
8 X) g9 i& h; }+ n/ h" c5 Psshd: ALL" A5 A5 P  q) O7 u' i8 X, `
# vim /etc/hosts.allow
" x( r  w1 `1 T2 G; v% v/ X, rsshd: 192.168.1 1.2.3.4 # 閮 192.168.1.* 1.2.3.4 蝺
  g& P$ _& G7 @: s5 c
3 X  [" g) @. H5 z" F9.雿輻 iptables 嗡皞 IP
5 V: }# d+ r7 Z- I; b/ n# iptables -A INPUT -p tcp -m state --state NEW --source 1.2.3.4 --dport 22 -j ACCEPT' G, a3 ^2 D/ Q1 L" v5 A
# iptables -A INPUT -p tcp --dport 22 -j DROP
& z" z5 z2 u+ Z; b$ X閮剖蝡喟嚗亙璈敺賭摮嚗閬脣 iptables 閮剖
) i$ K' H8 k  d; W1 J  C
0 y, ^, F& z4 w+ {+ |% [: ^10.摰  Z+ r! T) n5 x& M! ~
雿臭誑雿輻其iptables訾嗅訕SH伐霈嗅其孵蝭批臭誑伐嗡銝賡乓雿臭誑其Y隞颱靘摮銝凋蝙 /second/minute/hour /day $ N+ I- `' [7 P) G# F- Z) j
蝚砌靘摮嚗憒銝冽嗉撓乩航炊撖蝣潘摰銝找閮勗刻赤SSH嚗璅瘥冽嗅其批芾賢閰虫甈∠駁
' h, J, {4 L' O6 n) N. t  # iptables -A INPUT -p tcp -m state --syn --state NEW --dport 22 -m limit --limit 1/minute --limit-burst 1 -j ACCEPT9 J9 @5 C, L+ P, X- r! [
  # iptables -A INPUT -p tcp -m state --syn --state NEW --dport 22 -j DROP* d. I3 J1 v4 n& m: Z) V
蝚砌靘摮嚗閮剔蔭iptables芸閮曹蜓璈193.180.177.13亙訕SH嚗典閰虫甈∪仃駁詨嚗iptables閮梯府銝餅瘥閰虫甈∠駁# s* L2 h/ H, U2 B2 S0 [2 f. B& t% [
  # iptables -A INPUT -p tcp -s 193.180.177.13 -m state --syn --state NEW --dport 22 -m limit --limit 1/minute --limit-burst 1 -j ACCEPT( [3 D8 y' D% G
  # iptables -A INPUT -p tcp -s 193.180.177.13 -m state --syn --state NEW --dport 22 -j DROP
) L, \" D; I& l: a' v2 q& q) o2 r- V( y& e/ ~; l, y
11.瑼X亦賊瑼獢甈嚗銝摰典銝閮梁餃7 e' Z; N& S9 U- O
StrictModes yes
0 p( \7 p+ E! Q0 E; r鈭賊瑼獢甈閮剖交航炊嚗航賡摰冽折◢芥憒雿輻刻 ~/.ssh/authorized_keys 甈亦 666嚗航賡嗡鈭箏臭誑典董. V8 Z+ y; k5 W, ^
* H4 O) g' a- q5 B- b; y2 u
12.芾雿輻刻餃交憿舐內 banner (閰梯牧頝摰冽扳隞暻潮靽...? 憭扳臭誑函冗鈭斗孵頝憯鈭箏...= =a)$ l+ k  Y! u8 I: {9 E
Banner /etc/ssh/banner # 隞餅摮瑼4 ~3 ?6 A) Q9 w# _, L
* I9 d7 D1 C/ P% G
13. su/sudo . m9 D. T+ h& F' Y% j
# vi /etc/pam.d/su; [2 y7 J) f3 h# Z5 z
    auth       required     /lib/security/$ISA/pam_wheel.so use_uid) B$ d- {4 x1 z; v: r) X) ?
# visudo  |/ A* G/ c) |/ S2 C
    %wheel  ALL = (ALL) ALL
5 k8 N4 @* ?  J, v  X# gpasswd -a user1 wheel" {, O. f1 Z1 N  z# v

5 G# W( \; U. h7 c6 g14. ssh 雿輻刻
. B9 a2 f' W% y5 B5 g6 }# vi /etc/pam.d/sshd2 u* Q3 P7 ?3 I* c
    auth required pam_listfile.so item=user sense=allow file=/etc/ssh_users onerr=fail( s! E* \& v9 O$ Q0 H
# echo <username> >> /etc/ssh_users
' O+ Q" y' y2 L( J; Y* m6 F15.脫迫SSH蝺暹(timeout),霈PuTTY SSH 銝港蝺
9 K  E' l, c+ {; i* X    靽格/etc/ssh/sshd_config5 [9 P2 o% r5 R, U& f* y0 B
#TCPKeepAlive yes
% J- x# X4 O9 W4 ]! E( L/ u#ClientAliveInterval 0: H/ e  d! W9 R/ L" F) w8 G
#ClientAliveCountMax 3

2 V0 b9 @# l+ @( d7 F1 D
     撠#踵==>摮瑼6 \1 v# Z. Q1 k4 a
#service ssd restart ==>sshd8 L' Z3 G$ P) ]: [% q
    乩靘靽格 Pietty 賂脣PuTTY 蝺閮剖:
9 h4 g, }7 z" A) k2 P* }    豢Connection殷撠Seconds between keepalives [0 to turn off]喲甈雿頛詨交撟曄嚗喲銝null撠隞乩蝺

7 b$ |% h& y! {5 J' k, T4 l) l5 x/ Z) `0 u* t* s

雿輻券

祉蝛閬

BT蝳

砍憛批捆靘餉衣雯頝臬批捆蝝颲行粹嗥蝬脩嚗摰撟湔遛嚗嚗甇脖誑銝嗅啣摰嗆摰撟湧翩鈭箏ㄚ孵舫脣伐銝憿亙祉璇甈橘芣遛18甇 雓蝯脣亦閬賬粹脩芣遛18甇脖芣撟渡雯閬賜雯頝臭嗥批捆鞈閮嚗撱箄降典舫脰蝬脰楝批捆蝝蝯蝜ICRA蝝摰鋆閮剖 (粹蝯行霅 祉蝬脣銝蝝瘛函隢憯啣嚗祉閮剜蝞∠)

QQ|撠暺撅||52AV璈A

GMT+8, 2024-11-22 16:39 , Processed in 0.061013 second(s), 17 queries .

蝯∠.撱

[email protected] | QQ:2405733034     since 2015-01

鋆貉憒 敹恍敺 餈銵