A. linuxssh娌″弽搴攍inuxssh涓嶄笂
SSH鏈嶅姟鍣ㄥけ璐ユ庝箞鍔烇紵
鍒嗕韓涓変釜SSH鏈嶅姟鍣ㄥけ璐ョ殑淇澶嶅姙娉曪細瑙e喅鏂規硶錛
涓銆佸紑鍚瘲SH浠root鐢ㄦ埛鐧誨綍Linux錛屾墦寮緇堢錛岃繍琛岋細/etc/init.d/sshdrestrat浜屻佸叧闂闃茬伀澧1銆佸湪緇堢榪愯宻etup2銆侀夋嫨firewall鍥炶濺3銆佹寜tab閿鍒囨崲鍒癲isablede欏癸紝鐒跺悗鎸夌┖鏍奸敭閫夋嫨錛岀劧鍚庡啀鎸塼ab閿鍒囨崲鍒皁k錛屾寜絀烘牸浠墮夋嫨4銆佹寜tab閿鍒囨崲鍒皅uit錛屾寜絀烘牸浠墮夋嫨鐒跺悗鐢ㄥ㈡埛絝痵sh鐧誨綍Linux錛屾垚鍔熺櫥褰曘
涓夈佸叧闂闃茬伀澧欑殑鍙︿竴縐嶆柟寮忚ˉ鍏呬竴涓錛岀孩鏃條inux鐨勬煇浜涚増鏈錛屼笉鍏佽竢oot鐢ㄦ埛榪滅▼鐧婚檰鐨勶紝闇瑕佷慨鏀硅劇疆#vi/etc/ssh/sshd_config涓璓ermitRootLoginno#榪欏氨涓嶅厑璁竢oot鐢ㄦ埛榪滅▼鐧誨綍錛岃佷慨鏀規垚PermitRootLoginyes騫墮噸鍚痵shd鏈嶅姟鎵嶈岀殑銆#servicesshdrestart閲嶆柊鐧誨綍OK銆
涓轟粈涔坰sh閾炬帴澶辮觸錛
瑙e喅鏂規硶錛
涓銆佸紑鍚瘲SH
浠root鐢ㄦ埛鐧誨綍Linux錛屾墦寮緇堢錛岃繍琛岋細/etc/init.d/sshdrestrat
浜屻佸叧闂闃茬伀澧
1.鍦ㄧ粓絝榪愯宻etup
2,.閫夋嫨firewall鍥炶濺
3.鎸塼ab閿鍒囨崲鍒癲isablede欏癸紝鐒跺悗鎸夌┖鏍奸敭閫夋嫨錛岀劧鍚庡啀鎸塼ab閿鍒囨崲鍒皁k錛屾寜絀烘牸浠墮夋嫨
4.鎸塼ab閿鍒囨崲鍒皅uit錛屾寜絀烘牸浠墮夋嫨
鐒跺悗鐢ㄥ㈡埛絝痵sh鐧誨綍Linux錛屾垚鍔熺櫥褰曪紝鍛靛懙^_^
涓夈佸叧闂闃茬伀澧欑殑鍙︿竴縐嶆柟寮
/etc/init.d/iptablesstop
琛ュ厖涓涓錛岀孩鏃條inux鐨勬煇浜涚増鏈錛屼笉鍏佽竢oot鐢ㄦ埛榪滅▼鐧婚檰鐨勶紝闇瑕佷慨鏀硅劇疆#vi/etc/ssh/sshd_config涓
PermitRootLoginno
#榪欏氨涓嶅厑璁竢oot鐢ㄦ埛榪滅▼鐧誨綍錛岃佷慨鏀規垚PermitRootLoginyes騫墮噸鍚痵shd鏈嶅姟鎵嶈岀殑
#servicesshdrestart
鐨刲inux鐧誨綍涓嶈繘鍘繪槸鎬庝箞鍥炰簨錛
1.闂棰樿存槑
Linux榪滅▼鏈嶅姟鍣ㄧ獊鐒舵棤娉昐SH鐧誨綍浜嗭紝
鐧婚檰鎶ラ敊錛
ssh_exchange_identification:read:Connectionresetbypeer銆
2.闂棰樺師鍥
var鐩褰曠殑鏉冮檺涓嶆g『
3.瑙e喅鍔炴硶
灝哠SH鐩稿叧鏂囦歡鐨勬潈闄愭敼鍥炴潵錛岀『淇濇潈闄愪負755錛屽睘涓諱負root:root銆
榪欓噷鍙浠ヤ嬌鐢╲ps鏈嶅姟鍣ㄧ殑svn鍔熻兘錛岃繘琛岀櫥褰曠郴緇燂紝vps鎻愪緵鍟嗛兘浼氭彁渚泇nc鐧誨綍鍔熻兘銆
ssh榪炰笉涓妉inux鉶氭嫙鏈篊md鑳借繛錛
ssh榪炰笉涓奓inux鉶氭嫙鏈篶md鑳絧ing閫氾紝璇存槑緗戣礬娌℃湁闂棰橈紝ssh榪炴帴涓嶄笂闇瑕侀厤緗畇sh瀵嗛掗
linux鍙浠PING閫氾紝浣哠SH榪炴帴涓嶄笂錛屽備綍瑙e喅錛
鍘熷洜錛氳闃茬伀澧欐尅鎺夛紝ssh鏈嶅姟閰嶇疆鏂囦歡涓鐨勫弬鏁版槸鍚︽嫆緇濅簡榪炴帴絳夌瓑銆傝В鍐蟲柟娉曪細
涓銆佸紑鍚瘲SH銆
浠root鐢ㄦ埛鐧誨綍Linux錛屾墦寮緇堢錛岃繍琛岋細/etc/init.d/sshdrestrat銆
浜屻佸叧闂闃茬伀澧欍
1.鍦ㄧ粓絝榪愯宻etup銆
2,.閫夋嫨firewall鍥炶濺銆
3.鎸塼ab閿鍒囨崲鍒癲isablede欏癸紝鐒跺悗鎸夌┖鏍奸敭閫夋嫨錛岀劧鍚庡啀鎸塼ab閿鍒囨崲鍒皁k錛屾寜絀烘牸浠墮夋嫨銆
4.鎸塼ab閿鍒囨崲鍒皅uit錛屾寜絀烘牸浠墮夋嫨銆傜劧鍚庣敤瀹㈡埛絝痵sh鐧誨綍Linux銆
涓夈佸叧闂闃茬伀澧欑殑鍙︿竴縐嶆柟寮忋/etc/init.d/iptablesstop銆
鍥涖佸傛灉ping涓嶅悓錛屽傛灉鏄鍦╒mware涓瀹夎呯殑linux錛岄渶瑕佸湪鉶氭嫙鏈鴻劇疆涓錛屽皢NetworkAdapter璁劇疆鎴怋ridged錛堟ˉ鎺ワ級錛屽洜涓洪粯璁ゆ槸鈥淣AT鈥濄
B. ssh命令連接伺服器提示許可權拒絕
在/etc/ssh/sshd_config中有一個選項StrictModes,如果該選項是yes,那麼如果某些文件或者文件夾的許可權不對則無法ssh登錄,具體許可權如下
chmod g-w /home/your_user
chmod 700 /home/your_user/.ssh
chmod 600 /home/your_user/.ssh/authorized_keys