[20201120]cygwin與ssh.txt

lfree發表於2020-11-20

[20201120]cygwin與ssh.txt

--//昨天安裝cygwin後,今天安裝openssh,發現cygwin的ssh無法連線測試伺服器,提示:

$ ssh -l root 192.168.100.78
Unable to negotiate with 192.168.100.78 port 22: no matching key exchange method found. Their offer:
diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1

--//上網看一個一些連結:
$ cd ~
$ mkdir .ssh
$ cd .ssh
$ touch config
$ chmod 660 config

$ cat config
Host *
KexAlgorithms +diffie-hellman-group1-sha1

--//這樣就可以ok了。
--//我使用strace跟蹤發現:
$ strace ssh -l root 192.168.100.78 | grep "/etc/"
   15    3207 [main] ssh (6576) mount_info::conv_to_posix_path: /etc/ssh = conv_to_posix_path (D:\tools\cygwin64\etc\ssh)
   20    5562 [main] ssh 2018 win32env_to_cygenv: 0x8000290F0: PWD=/etc/ssh
   91   86350 [main] ssh 2018 open: open(/etc/ssh_config, 0x0)
   12   86362 [main] ssh 2018 normalize_posix_path: src /etc/ssh_config
   13   86375 [main] ssh 2018 normalize_posix_path: /etc/ssh_config = normalize_posix_path (/etc/ssh_config)
   14   86389 [main] ssh 2018 mount_info::conv_to_win32_path: conv_to_win32_path (/etc/ssh_config)
   13   86402 [main] ssh 2018 mount_info::conv_to_win32_path: src_path /etc/ssh_config, dst D:\tools\cygwin64\etc\ssh_config, flags 0x30008, rc 0
   12   86850 [main] ssh 2018 open: -1 = open(/etc/ssh_config, 0x8000), errno 2
  104  138357 [main] ssh 2018 open: open(/etc/ssh_known_hosts, 0x0)
   13  138370 [main] ssh 2018 normalize_posix_path: src /etc/ssh_known_hosts
   13  138383 [main] ssh 2018 normalize_posix_path: /etc/ssh_known_hosts = normalize_posix_path (/etc/ssh_known_hosts)
   16  138399 [main] ssh 2018 mount_info::conv_to_win32_path: conv_to_win32_path (/etc/ssh_known_hosts)
   15  138414 [main] ssh 2018 mount_info::conv_to_win32_path: src_path /etc/ssh_known_hosts, dst D:\tools\cygwin64\etc\ssh_known_hosts, flags 0x30008, rc 0
   17  138943 [main] ssh 2018 open: -1 = open(/etc/ssh_known_hosts, 0x8000), errno 2
  102  139045 [main] ssh 2018 open: open(/etc/ssh_known_hosts2, 0x0)
   16  139061 [main] ssh 2018 normalize_posix_path: src /etc/ssh_known_hosts2
   15  139076 [main] ssh 2018 normalize_posix_path: /etc/ssh_known_hosts2 = normalize_posix_path (/etc/ssh_known_hosts2)
   18  139094 [main] ssh 2018 mount_info::conv_to_win32_path: conv_to_win32_path (/etc/ssh_known_hosts2)
   13  139107 [main] ssh 2018 mount_info::conv_to_win32_path: src_path /etc/ssh_known_hosts2, dst D:\tools\cygwin64\etc\ssh_known_hosts2, flags 0x30008, rc 0
   18  139599 [main] ssh 2018 open: -1 = open(/etc/ssh_known_hosts2, 0x8000), errno 2
Unable to negotiate with 192.168.100.78 port 22: no matching key exchange method found. Their offer: diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1

--//實際上系統配置在/etc/ssh_config.我開始修改D:\tools\cygwin64\etc\defaults\etc\sshd_config檔案不對。
--//把檔案D:\tools\cygwin64\etc\defaults\etc\sshd_config複製到D:\tools\cygwin64\etc\sshd_config,加入
Host *
KexAlgorithms +diffie-hellman-group1-sha1

--//一樣可以正常登入。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2735441/,如需轉載,請註明出處,否則將追究法律責任。

相關文章