Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
SSH:localhost在成功登录后关闭连接_Ssh_Terminal_Osx Server - Fatal编程技术网

SSH:localhost在成功登录后关闭连接

SSH:localhost在成功登录后关闭连接,ssh,terminal,osx-server,Ssh,Terminal,Osx Server,当我尝试ssh到localhost时,它接受公钥并立即关闭连接。我已经浏览谷歌搜索结果页面好几个小时了,没有任何进展。下面是我在ssh-v之后得到的user@localhost: OpenSSH_5.9p1, OpenSSL 0.9.8r 8 Feb 2011 debug1: Reading configuration data /Users/user/.ssh/config debug1: Reading configuration data /etc/ssh_config debug1: /

当我尝试ssh到localhost时,它接受公钥并立即关闭连接。我已经浏览谷歌搜索结果页面好几个小时了,没有任何进展。下面是我在
ssh-v之后得到的user@localhost

OpenSSH_5.9p1, OpenSSL 0.9.8r 8 Feb 2011
debug1: Reading configuration data /Users/user/.ssh/config
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: Connecting to localhost [::1] port 22.
debug1: Connection established.
debug1: identity file /Users/user/.ssh/id_rsa type -1
debug1: identity file /Users/user/.ssh/id_rsa-cert type -1
debug1: identity file /Users/user/.ssh/id_dsa type 2
debug1: identity file /Users/user/.ssh/id_dsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9
debug1: match: OpenSSH_5.9 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA 67:2f:0b:c8:40:e8:87:0f:57:ee:c7:68:ae:8a:5a:02
debug1: Host 'localhost' is known and matches the RSA host key.
debug1: Found key in /Users/user/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Trying private key: /Users/user/.ssh/id_rsa
debug1: Offering DSA public key: /Users/user/.ssh/id_dsa
debug1: Server accepts key: pkalg ssh-dss blen 433
debug1: read PEM private key done: type DSA
Connection closed by ::1
OpenSSH_5.9p1,OpenSSL 0.9.8r 2011年2月8日
debug1:正在读取配置数据/Users/user/.ssh/config
debug1:读取配置数据/etc/ssh\u config
debug1:/etc/ssh\u配置第20行:应用*
debug1:连接到本地主机[::1]端口22。
debug1:已建立连接。
debug1:identity file/Users/user/.ssh/id\u rsa type-1
debug1:identity file/Users/user/.ssh/id\u rsa-cert类型-1
debug1:identity file/Users/user/.ssh/id_dsa类型2
debug1:标识文件/Users/user/.ssh/id_dsa-cert类型-1
debug1:远程协议版本2.0,远程软件版本OpenSSH_5.9
debug1:match:OpenSSH_5.9 pat OpenSSH*
debug1:启用协议2.0的兼容模式
debug1:本地版本字符串SSH-2.0-OpenSSH_5.9
debug1:SSH2\u MSG\u KEXINIT已发送
debug1:SSH2\u MSG\u KEXINIT已收到
debug1:kex:server->client aes128 ctr hmac-md5无
debug1:kex:客户端->服务器aes128 ctr hmac-md5无

debug1:SSH2_MSG_KEX_DH_GEX_REQUEST(1024很久以前,我对Telnet也有同样的问题,如果我记得很清楚的话,问题是用户在/etc/passwd中没有主目录。 我假设您正在尝试创建无密码连接,对吗? 当你用谷歌搜索它时,这里有一个很好的解释:
此外,这里还解释了如何快速实现无密码连接,因此最终有效的方法是明确允许来自
用户的连接。设置
系统首选项>共享>远程登录>允许访问:
所有用户的连接不起作用;相反,我必须只检查
这些用户:
and手动添加所有用户。希望这能帮助其他有同样问题的人。

这对我在Cygwin中使用Windows在一个大域中工作很有效:

将您的Windows用户ID添加到
/etc/passwd
。您可以通过键入$
mkpasswd-d | grep[username]
来获得它。在一个大型域中,您可能需要等待数小时


确保
/etc/passwd
中给出的用户ID与$
ID-u
中的用户ID相匹配,组ID与
/etc/group

中管理员的用户ID相匹配。我如何设置主目录/检查主目录是否存在?对于链接,第一个没有帮助,第二个只是出错,说:
Connecti在被127.0.0.1关闭的连接被127.0.0.1关闭的主机名=
此外,无密码连接已经工作,如我上面所说,在连接关闭之前接受公钥。是的,你是对的。绵羊的眼睛催眠了我;)对不起,回答太快了。我只能给你一些想法,你可能会觉得不那么聪明,但谁知道呢。如果MaxStartups/etc/ssh/sshd_config显示为1,那么这可能是问题所在,因为您实际上会同时打开两个连接。当然,如果您做了更改,您需要重新启动sshd。我已经在我的机器上运行了一个测试,在尝试publickey时它有一点不同:…:(((我不知道如何粘贴它以使其断线,您可以看到输出…debug1:下一个身份验证方法:publickey debug1:尝试私钥:/root/.ssh/identity debug1:提供公钥:/root/.ssh/id\u rsa debug1:服务器接受密钥:pkalg ssh rsa blen 277 debug1:读取PEM私钥完成:键入rsa debug1:身份验证su)cceeded(publickey).debug1:channel 0:new[client session]debug1:Entering interactive session.debug1:Sending environment.Checked
/etc/sshd\u config
MaxStartups
被注释掉。不确定默认值是什么,但我取消了注释并将其设置为10.重新启动了sshd(在系统预置中切换远程登录),但输出没有更改。此外,根据调试输出,可能我的密钥根本不被接受;我的密钥在身份验证成功之前停止
,所以可能是我的密钥有问题。这听起来不像是ssh设置。也许你应该标记这个问题?这不是ssh设置,但它必须直接与ssh有关。添加osx服务器标记的好主意,我现在就这么做。+1非常好,没有文档,不可能从sshd日志中得到。说真的MacOS的诡异之处。谢谢你,Sheep先生。谢谢你的分享!我在git和ssh配置上看了好几个小时,直到偶然发现你的答案。对我来说,“所有这些用户”都启用了,但没有添加用户。当我将用户添加到“所有这些用户”时,它工作了。有趣的是,当我选择“所有用户”时,它也工作了