Jac*_*ton 5 login ssh cygwin logout sshd
我读过几乎所有关于这个问题的变体的谷歌链接,但它们似乎都不适用,这让我感到困惑。
除了我的许多 Linux 计算机之外,我还有一台安装了 Cygwin 的 Windows 10 笔记本电脑,通过其安装文件完全更新了 Windows 更新和 Cygwin 更新。它有一个管理员用户(严格用于维护)和两个分配给用户组(且不属于其他组的成员)的非管理员用户帐户,用于日常操作。所有三个帐户多年来都完美运行,Cygwin 能够启动各自的 cygwin 终端和/或通过 SSH 登录到本地主机。本月,由于某种未知原因,User1 帐户无法启动 Cygwin 终端。相反,它总是提示输入管理密码。如果选择“否”,Cygwin 终端将永远不会打开。如果您单击“是”并提供管理员密码,您实际上并没有以 User1 身份登录,这是一个问题,因为 User1 不需要是管理员,并且需要访问自己的 git 文件、存储库等来推送/拉取其更新。
如果管理员运行“ssh User1@localhost”,它会通过密码身份验证,但会立即被踢出并显示以下类型的消息:
Last login: Sat Apr 1 21:57:31 2017 from ::1
Connection to localhost closed.
Run Code Online (Sandbox Code Playgroud)
请注意,上次登录确认登录成功,但总是会立即退出。使用 User2 运行相同的命令没有问题,确认 sshd 工作正常。
通过管理员帐户从 cygwin 终端运行“login User1”会导致提示输入 User1 的密码,成功输入后,再次被踢出并显示以下消息:
Password:
Switching to user User1 failed!
Run Code Online (Sandbox Code Playgroud)
User2 做这些事情绝对没有问题。请记住,User1 过去能够在上个月和过去几年中完成所有这些操作。
我重新安装了 sshd (甚至通过 Cygwin 安装文件升级了它)并重新运行 ssh-host-config 但似乎没有任何帮助。(ssh 适用于 Admin 和 User2。)这是我已经检查过的内容。
find /etc -type f -exec grep -il User1 {} \;
Run Code Online (Sandbox Code Playgroud)
mkpasswd -l > /etc/passwd
mkgroup -l > /etc/group
Run Code Online (Sandbox Code Playgroud)
User1:*:197609:197121:U-Jack-VAIO\User1,S-1-5-21-2974605114-333831212-2175464639-1001:/home/User1:/bin/bash
User2:*:197610:197121:U-Jack-VAIO\User2,S-1-5-21-2974605114-333831212-2175464639-1002:/home/User2:/bin/bash
Run Code Online (Sandbox Code Playgroud)
User1 可以正常登录 Windows。(compmgmt.msc > 用户中未禁用,密码也未过期。)
我已删除 /etc/passwd 和 /etc/group 因为它们在当前的 Cygwin 中不再需要。
我已在“本地用户和组”中确认 User1 的描述为空(这是可以接受的,并且是当 /etc/passwd 不存在时 Cygwin 查找 /etc/passwd 字段的替代位置)。
“Cygwin Terminal.lnk”快捷方式与 User2 使用的快捷方式完全相同,没有任何问题。它位于 /cygdrive/c/Users/Public/Desktop 中。(它没有选中“以管理员身份运行”复选框。但是,系统会提示 User1 输入管理员密码。)
User1 的 .bashrc 或 .bash_profile 中没有任何内容可以使其退出。(参见下一个项目符号。)
User1 的 /home/User1 权限与 User2 的相同。事实上,我什至尝试将 /home/User1 移动到另一个名称,创建一个新的 /home/User1 ,其中什么都没有(相同的结果),然后复制 /etc/skel 并将权限更改为 chown -R User1 :无(相同结果)。
drwxr-xr-x+ 1 Admin None 0 Apr 1 22:07 Admin
drwxr-xr-x+ 1 User1 None 0 Apr 1 21:52 User1
drwxr-xr-x+ 1 User1 None 0 Apr 1 21:56 User1.001
drwxr-xr-x+ 1 User1 None 0 Apr 1 18:05 User1.old
drwxr-xr-x+ 1 User2 None 0 Oct 21 09:36 User2
drwxr-xr-x+ 1 User1 None 0 Apr 1 21:52 .
drwxrwxrwt+ 1 Admin None 0 Apr 2 06:48 ..
-rw-r--r-- 1 User1 None 1494 Jan 16 15:07 .bash_profile
-rw-r--r-- 1 User1 None 6054 Jan 16 15:07 .bashrc
-rw-r--r-- 1 User1 None 1919 Jan 16 15:07 .inputrc
-rw-r--r-- 1 User1 None 1236 Jan 16 15:07 .profile
Run Code Online (Sandbox Code Playgroud)
这是 ssh -vvv User1@localhost 与 User2 的样子。我只包含了验证成功后的部分,以便您可以看到差异。
用户1:
debug1: Next authentication method: password
User1@localhost's password:
debug3: send packet: type 50
debug2: we sent a password packet, wait for reply
debug3: receive packet: type 52
debug1: Authentication succeeded (password).
Authenticated to localhost ([::1]:22).
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug3: send packet: type 90
debug1: Requesting no-more-sessions@openssh.com
debug3: send packet: type 80
debug1: Entering interactive session.
debug1: pledge: network
debug3: receive packet: type 80
debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0
debug3: receive packet: type 91
debug2: callback start
debug2: fd 3 setting TCP_NODELAY
debug3: ssh_packet_set_tos: set IPV6_TCLASS 0x10
debug2: client_session2_setup: id 0
debug2: channel 0: request pty-req confirm 1
debug3: send packet: type 98
debug2: channel 0: request shell confirm 1
debug3: send packet: type 98
debug2: callback done
debug2: channel 0: open confirm rwindow 0 rmax 32768
debug3: receive packet: type 99
debug2: channel_input_status_confirm: type 99 id 0
debug2: PTY allocation request accepted on channel 0
debug2: channel 0: rcvd adjust 2097152
debug3: receive packet: type 99
debug2: channel_input_status_confirm: type 99 id 0
debug2: shell request accepted on channel 0
Last login: Sun Apr 2 06:43:18 2017 from ::1
debug3: receive packet: type 96
debug2: channel 0: rcvd eof
debug2: channel 0: output open -> drain
debug2: channel 0: obuf empty
debug2: channel 0: close_write
debug2: channel 0: output drain -> closed
debug3: receive packet: type 98
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug3: receive packet: type 98
debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0
debug2: channel 0: rcvd eow
debug2: channel 0: close_read
debug2: channel 0: input open -> closed
debug3: receive packet: type 97
debug2: channel 0: rcvd close
debug3: channel 0: will not send data after close
debug2: channel 0: almost dead
debug2: channel 0: gc: notify user
debug2: channel 0: gc: user detached
debug2: channel 0: send close
debug3: send packet: type 97
debug2: channel 0: is dead
debug2: channel 0: garbage collecting
debug1: channel 0: free: client-session, nchannels 1
debug3: channel 0: status: The following connections are open:
#0 client-session (t4 r0 i3/0 o3/0 fd -1/-1 cc -1)
debug3: send packet: type 1
Connection to localhost closed.
Transferred: sent 2248, received 2868 bytes, in 0.1 seconds
Bytes per second: sent 15979.1, received 20386.1
debug1: Exit status 255
Admin@Jack-VAIO ~
$
Run Code Online (Sandbox Code Playgroud)
用户2:
debug1: Next authentication method: password
User2@localhost's password:
debug3: send packet: type 50
debug2: we sent a password packet, wait for reply
debug3: receive packet: type 52
debug1: Authentication succeeded (password).
Authenticated to localhost ([::1]:22).
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug3: send packet: type 90
debug1: Requesting no-more-sessions@openssh.com
debug3: send packet: type 80
debug1: Entering interactive session.
debug1: pledge: network
debug3: receive packet: type 80
debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0
debug3: receive packet: type 91
debug2: callback start
debug2: fd 3 setting TCP_NODELAY
debug3: ssh_packet_set_tos: set IPV6_TCLASS 0x10
debug2: client_session2_setup: id 0
debug2: channel 0: request pty-req confirm 1
debug3: send packet: type 98
debug2: channel 0: request shell confirm 1
debug3: send packet: type 98
debug2: callback done
debug2: channel 0: open confirm rwindow 0 rmax 32768
debug3: receive packet: type 99
debug2: channel_input_status_confirm: type 99 id 0
debug2: PTY allocation request accepted on channel 0
debug2: channel 0: rcvd adjust 2097152
debug3: receive packet: type 99
debug2: channel_input_status_confirm: type 99 id 0
debug2: shell request accepted on channel 0
Last login: Sat Apr 1 20:56:04 2017 from ::1
User2@Jack-VAIO ~
$
Run Code Online (Sandbox Code Playgroud)
setreuid 197609: Operation not permitted
setresuid 197609: Operation not permitted
Run Code Online (Sandbox Code Playgroud)
所以你有它。我完全困惑了。需要注意的一件事是,从 Windows 中删除 User1 并重新创建不是一个选项,因为我已经设置了多年的配置设置,并且不会重新创建,特别是当 User1 和 User2 的其他一切都正常工作时。User1 无法再访问自己的 Cygwin 帐户。
关于还有什么要检查的任何想法,因为我刚刚摆脱它们。
PS 感谢您阅读本文。
经过进一步研究(此处和此处),我倾向于认为问题不在于 Cygwin,而在于 Windows 10。昨天,当我在 User2 的 Windows 帐户中时,我的脑海中突然灵光一闪,注意到我可以启动任务管理器没有 UAC 提示——我知道 User1 在从 Windows 8 升级到 Windows 10 后总是会收到提示(尽管该升级是在大约一年前免费升级到 Win 10 促销期间进行的)。我认为这是 Windows 10 的事情,并且没有多想。当我意识到 User2 发生这种情况时,并在 google 上搜索解决方法来修复 User1 的问题,我发现我可以对 User1 的 Cygwin 问题使用相同的解决方法。它仍然没有回答 User1 的帐户最初是如何混乱的,也没有回答如何以正确的方式实际修复它,但我对这个解决方法感到满意,因为我现在可以为 User1 完成 git 更改。
长话短说
解决方法:
set __compat_layer=runasinvoker
Run Code Online (Sandbox Code Playgroud)
c:\cygwin64\bin\mintty.exe
Run Code Online (Sandbox Code Playgroud)
setx __compat_layer "runasinvoker"
Run Code Online (Sandbox Code Playgroud)
setx /m __compat_layer "runasinvoker"
Run Code Online (Sandbox Code Playgroud)
警告:由于 User1 帐户在技术上仍然损坏,我仍然无法使用 ssh 登录,但我至少可以以 User1 身份访问本地 Cygwin 终端。此外,此解决方法无法修复通过 sysdm.cpl GUI 修改 User1 的 Windows 用户环境变量的能力(仍然获得 UAC 提示,然后仅显示管理员的 ENV 变量而不是 User1 的),但这现在是 Windows 相关的 Stack Exchange 论坛的内容我知道这是 Windows 帐户问题,而不是 Cygwin 的问题。SETX 允许从命令行更改用户和机器 ENV 变量。
| 归档时间: |
|
| 查看次数: |
1871 次 |
| 最近记录: |