2010-01-29 82 views
15

我是Linux的粉丝,但由于Linux中坏的英特尔无线驱动程序,我不得不切换到Windows 7.我已经在Windows中安装了Cygwin,并且想要配置SSH以远程连接我的笔记本电脑。Cygwin SSH的目录权限(Windows 7)

我搜索谷歌和发现information for installing openssh server on Win 7,但运行ssh-host-config当我收到以下错误:

 
[email protected] ~ 
$ ssh-host-config 
yes 
*** Info: Creating default /etc/ssh_config file 
*** Query: Overwrite existing /etc/sshd_config file? (yes/no) yes 
*** Info: Creating default /etc/sshd_config file 
*** Info: Privilege separation is set to yes by default since OpenSSH 3.3. 
*** Info: However, this requires a non-privileged account called 'sshd'. 
*** Info: For more info on privilege separation read /usr/share/doc/openssh/READ 
ME.privsep. 
*** Query: Should privilege separation be used? (yes/no) no 
*** Info: Updating /etc/sshd_config file 

*** Warning: The following functions require administrator privileges! 

*** Query: Do you want to install sshd as a service? 
*** Query: (Say "no" if it is already installed as a service) (yes/no) yes 
*** Query: Enter the value of CYGWIN for the daemon: [] 
*** Info: On Windows Server 2003, Windows Vista, and above, the 
*** Info: SYSTEM account cannot setuid to other users -- a capability 
*** Info: sshd requires. You need to have or to create a privileged 
*** Info: account. This script will help you do so. 

*** Warning: The owner and the Administrators need 
*** Warning: to have .w. permission to /var/run. 
*** Warning: Here are the current permissions and ACLS: 
*** Warning:  drwxr-xr-x 1 bala None 0 2010-01-17 22:34 /var/run 
*** Warning:  # file: /var/run 
*** Warning:  # owner: bala 
*** Warning:  # group: None 
*** Warning:  user::rwx 
*** Warning:  group::r-x 
*** Warning:  other:r-x 
*** Warning:  mask:rwx 
*** Warning: 
*** Warning: Please change the user and/or group ownership, 
*** Warning: permissions, or ACLs of /var/run. 

*** ERROR: Problem with /var/run directory. Exiting. 

此文件夹的权限都显示为只读(仅适用于本文件夹),检查灰色。我试图取消选中,但在我再次打开属性后,该框再次被检查。有没有办法改变这个文件夹的权限?

+2

它与窗口UAC有关吗?如果您使用管理员运行Cygwin,它会发生吗? – Tommy 2010-01-29 03:33:42

+0

我实际上在我的机器中禁用了UAC。即使在使用“以管理员身份运行”时也会发生这种情况 – Boolean 2010-01-29 03:38:42

+0

这是超级用户吗?这不是与编程相关的。 – Catchwa 2010-01-29 04:15:28

回答

5

我在Windows 7 x64和sshd上运行cygwin 1.7。我不记得收到此错误,当我跑的sshd_config,但我只是看着我的/ var/run中的目录和它的设置为777

在cygwin外壳chmod 777 /var/run

+1

+1。更改Cygwin中的权限,然后重试。 – Arkaaito 2010-01-29 03:41:04

+0

我也试过这个选项。 巴拉@巴拉-PC〜 巴拉@巴拉-PC〜 $ CHMOD 777的/ var /运行 巴拉@巴拉-PC〜 $ LS -l/VAR 总0 drwxr-XR-X 1巴拉没有0 2010-01-17 22:34缓存 drwxr-xr-x 1 bala无0 2010-01-17 22:35 cron drwxr-xr-x 1 bala无0 2010-01-23 11:46空 drwxr-xr-x 1 bala None 0 2010-01-17 22:34 lib drwxr-xr-x 1 bala None 0 2010-01-17 22:32 log drwxr-xr-x 1 bala None 0 2010-01 -17 22:34运行 drwxr-xr-x 1 bala无0 2010-01-17 22:34 tmp -rw-r - r-- 1 bala无0 2010-01-23 11:44 utmp – Boolean 2010-01-29 03:42:21

+0

对不起,输出似乎没有正确格式化。我也尝试-R 777选项。 – Boolean 2010-01-29 03:43:12

2

试试这个在cygwin外壳,确保你是管理员,则:

takeown /F "C:\cygwin" /R 
icacls "C:\cygwin" /grant Everyone:\(F\) /T 
icacls "C:\cygwin" 
chmod 777 -R "c:\cygwin" 
+2

这对我来说也是没有用的。我想为什么这对我们中的某些人不起作用的答案必须在于/ var/run的Windows权限。 *没有任何*但是,我已经完成了任何作用。我已经在/ var/run上删除了* all *权限,并且创建了一个广泛开放的权限。纳达。 – e40 2012-03-22 21:12:26

+2

对不起,这在我的情况下不起作用 – 2013-02-07 10:23:48

+0

这对win7,cygwin64工作: setfacl -b〜/ .ssh/config; chmod 0600〜/ .ssh/config;从http://superuser.com/questions/348694/bad-owner-or-permissions-error-using-cygwins-ssh-exe – mosh 2016-10-06 14:14:41

8

对不起,挖掘出这样一个古老的线程,但这个问题始终上来时,我用Google搜索这个特定的问题。

几个月后,我终于找到了解决方案。当我设置cygwin时,我没有在cygwin中正确创建我的用户和组帐户。这样做的主要方法是运行:

mkpasswd -l > /etc/passwd 
mkgroup -l > /etc/group 

如果您在使用域用户和passwd记录,你可以这样做:

mkpasswd -l -d > /etc/passwd 
mkgroup -l -d > /etc/group 

或者,如果你有一个非常大的网络状我的,你可能不是真的想要那样。另一种方法是只是用户的本地用户和组加上任何一个您当前登录为:

mkpasswd -l > /etc/passwd 
mkpasswd -c >> /etc/passwd 
mkgroup -l > /etc/group 
mkgroup -c >> /etc/group 

我这样做之后,我终于能够正常运行ssh主机-config来创建服务。

+0

您好马修,我试过这些选项,但它仍然不允许我提供一个“空白密码“ – 2013-02-07 10:23:14

+1

自从Cygwin 1.7.35开始,此建议已过时,其中获取用户名/组信息的默认方式来自本地Windows数据库(SAM或AD),具体取决于系统是否位于Windows域中。除非你有非常特殊的需要能够通过'/ etc'文件覆盖SAM/AD,否则你现在不应该拥有这些文件。参见[Cygwin用户指南第3章](https://cygwin.com/cygwin-ug-net/ntsec.html)。 – 2015-08-31 03:15:14

4

我自己有很多麻烦。我发现默认安装步骤工作得很好,只要我:

  1. 使用“以管理员身份运行”选项启动Cygwin shell作为管理用户。
  2. 禁用UAC。
  3. 禁用实时病毒防护。

在采取这些步骤,默认的安装步骤是:

  1. 从Cygwin的安装程序进行安装 “的OpenSSH”。
  2. 使用“以管理员身份运行”选项启动Cygwin shell作为管理用户。
  3. 从Cygwin shell运行“ssh-host-config”。
  4. 权限分离:是
  5. 新的本地帐户 “的sshd”:是
  6. 安装的sshd的服务:是
  7. CYGWIN值:ntsec tty的
  8. 不同的名称为 “cyg_server”:没有
  9. 创建新的特权用户帐户“cyg_server”:是
  10. 集“cyg_server”密码,并保存在安全的地方
  11. 净启动sshd

之后,在Windows 7 Professional和Home上一切正常。

如果你已经有一个失败的Cygwin sshd安装,最好做一个完整的卸载并重新开始。

这里是Cygwin的卸载说明如果你需要他们:http://cygwin.com/faq/faq.html#faq.setup.uninstall-all

0

我才能够成功运行的ssh主机-config脚本,当我型NTFS的硬盘上安装了Cygwin。当我将Cygwin安装在exFAT类型的闪存驱动器上时,ssh-host-config脚本不起作用。

0

我遇到了同样的问题。我相信,我的问题是因为我有一个自定义的/ etc/fstab文件,其中我使用“noacl”选项安装根文件夹。这里是我解决了这个问题:

  1. 移动定制/ etc/fstab文件的方式进行:

    mv /etc/fstab /etc/fstab.bak 
    

    或者,您也可以编辑你的/ etc/fstab文件,并删除noacl选项。

  2. 关闭所有Cygwin bash窗口和其他Cygwin进程或服务。如果您有任何Cygwin进程正在运行,它将使用旧的/ etc/fstab设置来挂载它们。

  3. 开始一个新的Cygwin bash窗口。

  4. 您可能需要运行以下命令。

    chmod +r /etc/passwd 
    chmod o+x /var 
    chmod +w /var/run 
    
  5. 手指交叉,运行ssh-主机配置,现在应该完成,没有错误。

  6. 如果您在步骤1中移动你的/ etc/fstab中,现在可以将其移回:

    mv /etc/fstab.bak /etc/fstab 
    
  7. 如果创建新用户第一次安装了Cygwin,更新/ etc/passwd文件后,否则这些用户可能无法登录通过SSH:

    mkpasswd -l > /etc/passwd 
    
  8. 此外,转到Windows防火墙,并允许C:/cygwin/usr/sbin/sshd.exe和C:/ Cygwin的/ usr/sbin目录/ SFTP -服务器。exe文件

3

我首先必须除去破碎的安装:

mkpasswd -l > /etc/passwd 
mkgroup -l > /etc/group 

然后我跑:

cygrunsrv --remove sshd 
rm -rf /var/log/sshd* /etc/ssh_host* /etc/sshd_config /var/empty 

然后生成的passwd &组如上所述

ssh-host-config -y 
cygrunsrv --start sshd 

并最终“setuid失败”的消息消失和登录工作。

1

在Windows资源管理器,文件夹/var

属性。
安全。
为文件夹和子文件夹添加完全控制 的组管理员。

它适合我。

+0

谢谢你,为我工作。 – WildDev 2015-06-29 19:32:29

0

对于Windows用户对快捷方式运行 “Cygwin的终端” 通过右键点击并运行它作为管理员 .... enter image description here

立即运行 “SSH-主机配置” 从Cygwin终端...它一定会工作。