sshd遠(yuǎn)程連接時(shí)超慢

1.問題描述

在vm上新安裝的虛擬機(jī)褐墅,centos7写穴,用宿主機(jī)的xshell遠(yuǎn)程連接的時(shí)候需要等待大概10s的樣子所意,嘗試通過debug的方式追溯下原因轨域。

2.實(shí)際操作

通過ssh -v執(zhí)行debug模式

[root@localhost ssh]# ssh -v root@192.168.239.100
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
debug1: Connecting to 192.168.239.100 [192.168.239.100] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4
debug1: match: OpenSSH_7.4 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 192.168.239.100:22 as 'root'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: curve25519-sha256 need=64 dh_need=64
debug1: kex: curve25519-sha256 need=64 dh_need=64
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:4WaFL0X+hj57QX2TNbGRY5wuXYOKEezqfthABkMYsiY
debug1: Host '192.168.239.100' is known and matches the ECDSA host key.
debug1: Found key in /root/.ssh/known_hosts:1
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug1: Next authentication method: gssapi-with-mic
**debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available (default cache: KEYRING:persistent:0)**

debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available (default cache: KEYRING:persistent:0)

從上述日志中伤为,可以發(fā)現(xiàn)我是GSS認(rèn)證未關(guān)導(dǎo)致驗(yàn)證無法通過咒循,只能等待超時(shí)后進(jìn)行下一步操作据途。
重啟服務(wù)后再次嘗試,依然連接緩慢叙甸,再次開啟debug模式查看原因

[root@localhost ssh]# ssh -v root@192.168.239.100
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
debug1: Connecting to 192.168.239.100 [192.168.239.100] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4
debug1: match: OpenSSH_7.4 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 192.168.239.100:22 as 'root'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: curve25519-sha256 need=64 dh_need=64
debug1: kex: curve25519-sha256 need=64 dh_need=64
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:4WaFL0X+hj57QX2TNbGRY5wuXYOKEezqfthABkMYsiY
debug1: Host '192.168.239.100' is known and matches the ECDSA host key.
debug1: Found key in /root/.ssh/known_hosts:1
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
**debug1: SSH2_MSG_EXT_INFO received**

這次是卡在debug1: SSH2_MSG_EXT_INFO received這里颖医,應(yīng)該是sshd服務(wù)自動(dòng)的參數(shù):UseDNS默認(rèn)為yes導(dǎo)致,即開啟DNS反向查詢認(rèn)證裆蒸,
再次修改sshd的配置文件熔萧,添加以下配置

UseDNS no

systemctl restart sshd重啟服務(wù)后再次嘗試ssh遠(yuǎn)程連接,秒通僚祷。

總結(jié)

本次ssh遠(yuǎn)程連接緩慢的原因:
1.GSS認(rèn)證未關(guān)閉
2.DNS返查未關(guān)閉

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末佛致,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子辙谜,更是在濱河造成了極大的恐慌俺榆,老刑警劉巖,帶你破解...
    沈念sama閱讀 222,378評論 6 516
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件装哆,死亡現(xiàn)場離奇詭異罐脊,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)蜕琴,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,970評論 3 399
  • 文/潘曉璐 我一進(jìn)店門萍桌,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人奸绷,你說我怎么就攤上這事梗夸。” “怎么了号醉?”我有些...
    開封第一講書人閱讀 168,983評論 0 362
  • 文/不壞的土叔 我叫張陵反症,是天一觀的道長。 經(jīng)常有香客問我畔派,道長铅碍,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 59,938評論 1 299
  • 正文 為了忘掉前任线椰,我火速辦了婚禮胞谈,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘憨愉。我一直安慰自己烦绳,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 68,955評論 6 398
  • 文/花漫 我一把揭開白布配紫。 她就那樣靜靜地躺著径密,像睡著了一般。 火紅的嫁衣襯著肌膚如雪躺孝。 梳的紋絲不亂的頭發(fā)上享扔,一...
    開封第一講書人閱讀 52,549評論 1 312
  • 那天底桂,我揣著相機(jī)與錄音,去河邊找鬼惧眠。 笑死籽懦,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的氛魁。 我是一名探鬼主播暮顺,決...
    沈念sama閱讀 41,063評論 3 422
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼呆盖!你這毒婦竟也來了拖云?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,991評論 0 277
  • 序言:老撾萬榮一對情侶失蹤应又,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后乏苦,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體株扛,經(jīng)...
    沈念sama閱讀 46,522評論 1 319
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,604評論 3 342
  • 正文 我和宋清朗相戀三年汇荐,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了洞就。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 40,742評論 1 353
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡掀淘,死狀恐怖旬蟋,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情革娄,我是刑警寧澤倾贰,帶...
    沈念sama閱讀 36,413評論 5 351
  • 正文 年R本政府宣布,位于F島的核電站拦惋,受9級特大地震影響匆浙,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜厕妖,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 42,094評論 3 335
  • 文/蒙蒙 一首尼、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧言秸,春花似錦软能、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,572評論 0 25
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至俱恶,卻和暖如春雹嗦,著一層夾襖步出監(jiān)牢的瞬間范舀,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,671評論 1 274
  • 我被黑心中介騙來泰國打工了罪, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留锭环,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 49,159評論 3 378
  • 正文 我出身青樓泊藕,卻偏偏與公主長得像辅辩,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個(gè)殘疾皇子娃圆,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,747評論 2 361