砍敺 IT_man 2018-9-13 18:28 蝺刻摩
7 h" M( Z8 _! V- O; Y0 q$ E& O' n. F
祉銝餉隞蝝孵linux client 撣唾撖蝣廣sh(Secure shell)追inux server銋閰喟敦蝔甇仿:* `, s( S# T0 X' v% p! r- ]
q# H& T1 G7 K! F0 j
<1> 每lient蝡舐YClient:
3 n0 d- A: N( W0 N* L# @+ o8 t" F
2 p+ N! i4 r+ |, M& c閮剖牢lient蝡臭誑雿輻刻 user1 餃,摰嗥桅 .ssh 桅鋆∴桀芣銝 known_hosts 瑼獢嚗舐其閮曄蝺啣亙啁server SSH Server 祇啜
" [( O2 c' p, ]9 U! K" E靘,Y銝蝯軏lient SSH 祇+蝘堆閮剜臭蝙 RSA 瞍蝞瘜 ==> ssh-keygen 隞 :- _+ b6 x, s* J" w/ w
" y# N/ C! @: {: A
0 H' s- w5 c8 X! \) U+ o! a
+ P3 ^0 n6 L: x8 v D; O5 j4 K7 z7 T: i2 ~0 o* j5 Y% t
蝔銝賊閬雿輻刻閮剖,銝敹靽格,券函湔交 Enter 券閮剖澆停憟賭1 T+ Y1 |4 r" y: m) C. M7 J
1. Enter file in which to save the key - 頛詨仿啁瑼獢頝臬蝔梧閮剜 ~/.ssh/id_rsa
/ w' E5 [. C: T) }1 p( ]1 Q2. Enter passphrase - 頛詨亥芾撖蝣潦, y X, B. a6 ^- N1 C* w; |* Y/ [: ]; p
3. Enter same passphrase again - 頛詨乩甈∟芾撖蝣潦
5 h9 c) t0 p1 O$ q' V2 o" L& S3 N& W, B# n" Q7 c, P+ D9 S0 m3 y
甇斗摰撠望Y id_rsa 蝘啣 id_rsa.pub 祇啜祇啁批捆嚗嗅祕撠勗芣臭撖摮撌脯9 l& L' A. Y8 @( U% s6 P
雿輻 scp ftp 雿蝧瑼獢唾撓撌亙瑕 Client 蝡舐祇 ~/.ssh/id_rsa.pub 銴鋆賢 Server蝡航ㄐ,撣唾閮凋真ser1,暻澆停祇啣 user1 摰嗥桅 ~ : y( e X% H1 k: W9 E8 [
5 l! n$ O5 y% w6 p, q* h$ f* D! t
<2> Server蝡臬亙Client蝡舐Y祇:
3 g( X4 W/ p+ P7 k' I: j& U# Z- S" b- E7 b( k) e
沒SH頠擃,閮凋誑Putty Server蝡,user1餃亙蝣箄銝銝 Client 祇 id_rsa.pub 撌脩鋡怨鋆賡脖,憒摰嗥桅瘝 .ssh 桅撠梯芾撱箇/ k6 D9 F4 _# _
.ssh 桅甈寞芣砌犖航撖,璅瘥頛摰具
" H8 U! t' x1 uchmod 700 ~/.ssh
1 D" n2 v [8 O銴鋆賡靘 Client 蝡臬祇堆臬亙 Server蝡舐甈皜(authorized_keys)鋆∼ 5 E( l" J, X2 [; u5 e
cat ~/id_rsa.pub >> ~/.ssh/authorized_keys
3 c+ a/ a' [# [0 U* x9 Z5 u
( [8 J/ \" o5 g/ M& F) L, V% Y5 o璅 authorized_keys 瑼獢甈芣砌犖航撖,璅瘥頛摰具" f( V9 \+ M7 U) F; a. R# i
chmod 600 ~/.ssh/authorized_keys, R7 m8 q0 O0 r
& d9 o7 F; ~2 ^; ^# {0 x+ A6 V. d e
R+ S/ X- v8 X& T0 s! H2 D, m* q9 _蝯:" ]9 I; o+ R) k6 B1 P' H& l
祉餃亦嚗閰W撣唾頝撖蝣潦撠 Client 蝡舐祇啣 Server蝡 甈桀,撠勗臭誑湔亦餃乩典董撖蝣潔,臭臬嫣噶,銝蝬SSH撖唾撓游具
" r$ d! Y- ~( ]' r+ s$ C: L孵亥牧:銝Y甇仿芣靘Client蝡舐雿輻刻user1撣唾撖蝣潛餃亙訕erver蝡舐雿輻刻user1;憒Client蝡舐雿輻刻user1甈脣撣唾撖蝣潛餃亙訕erver蝡舐雿輻刻root閰,甇仿<2>user1root,袖erver蝡舫隞叵oot餃,嗡雿賭璅6 J! c- ~8 S& x: o+ ?/ b
7 v% N9 `/ k# r8 w
3 o' h2 N- {& E5 y$ P& L
P.S 單澆Windows 撖蝣廣sh(Secure shell)追inux server,隢 http://blog.itist.tw/2015/03/login-ssh-server-without-username-and-password.html2 Y# |1 q( `( h! [3 f
8 o: i- p7 P+ b @6 o |
|