gpt4 book ai didi

ssh - cygwin 中的连接被::1 错误关闭

转载 作者:行者123 更新时间:2023-12-02 01:05:38 26 4
gpt4 key购买 nike

我正在尝试使用 cygwin 进行 ssh 连接。我已按照 here 给出的说明进行操作。当我开火时ssh localhost我得到命令Connection closed by ::1错误。由于我是 unix 和 cygwin 的新手,我无法弄清楚出了什么问题。请问谁能告诉我为什么会出现这个错误以及如何解决它?

我的 cygwin shell 如下所示:

$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/Shekhar/.ssh/id_rsa):
/home/Shekhar/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/Shekhar/.ssh/id_rsa.
Your public key has been saved in /home/Shekhar/.ssh/id_rsa.pub.
The key fingerprint is:
85:69:77:cc:fd:21:8a:ce:fe:46:41:ee:c8:e7:3d:7b Shekhar@Shekhar-PC
The key's randomart image is:
+--[ RSA 2048]----+
| |
| o + . |
| + = +... |
| . o.+. ...|
| S.o.. .|
| oo + |
| o+ . |
| . o o E |
| .o. .+ |
+-----------------+

Shekhar@Shekhar-PC ~
$ cd ~/.ssh/

Shekhar@Shekhar-PC ~/.ssh
$ ls -l
total 10
-rw-r--r-- 1 Shekhar None 1200 Jun 16 19:49 authorized_keys
-rw------- 1 Shekhar None 1675 Jun 20 08:55 id_rsa
-rw-r--r-- 1 Shekhar None 400 Jun 20 08:55 id_rsa.pub
-rw-r--r-- 1 Shekhar None 171 Jun 6 23:28 known_hosts

Shekhar@Shekhar-PC ~/.ssh
$ cat id_rsa.pub >> authorized_keys

Shekhar@Shekhar-PC ~/.ssh
$ ssh localhost
Connection closed by ::1

最佳答案

我也遇到过同样的问题。至少对我来说,问题是使用 ssh-host-config 创建 cyg_server 用户。它是在没有主目录的情况下创建的,并且其 shell 设置为/bin/false。因此,我更改了 cyg_server 用户的/etc/passwd 文件以反射(reflect)/home/cyg_server (从/var/empty 更改)和/bin/false 到/bin/bash 并为用户创建了主目录。尝试使用 cyg_server 用户重新连接,瞧。

简而言之:

mkdir /home/cyg_server
vim /etc/passwd
cyg_server:...(bunch of stuff)...:/var/empty:/bin/false

cyg_server:...(bunch of stuff)...:/home/cyg_server:/bin/bash

大概 cygwin 有一个 usermod 命令或同义词,可以更安全地做到这一点。但我很不耐烦,这就是我所做的。如果有人遵循此操作,请注意在编辑/etc/passwd 文件时要格外小心。

关于ssh - cygwin 中的连接被::1 错误关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11112431/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com