安装后如何更改Cygwin home文件夹?

时间:2022-01-21 00:29:41

I just installed Cygwin, and it looks like the home directory in the bash prompt is on my Z: drive. That's not where I want it.

我刚刚安装了Cygwin,它看起来就像bash提示中的主目录在我的Z:驱动器上。那不是我想要的。

How can I change this?

我怎样才能改变这个呢?

7 个解决方案

#1


145  

Starting with Cygwin 1.7.34, the recommended way to do this is to add a custom db_home setting to /etc/nsswitch.conf. A common wish when doing this is to make your Cygwin home directory equal to your Windows user profile directory. This setting will do that:

从Cygwin 1.7.34开始,推荐的方法是将自定义db_home设置添加到/etc/nsswitch.conf。这样做的一个常见愿望是使您的Cygwin主目录与您的Windows用户配置文件目录相同。这个设置将会这样做:

db_home: windows

Or, equivalently:

或者,相当于:

db_home: /%H

You need to use the latter form if you want some variation on this scheme, such as to segregate your Cygwin home files into a subdirectory of your Windows user profile directory:

您需要使用后一种形式,如果您想对该方案进行一些更改,比如将Cygwin home文件隔离到Windows用户配置文件目录的子目录中:

db_home: /%H/cygwin

There are several other alternative schemes for the windows option plus several other % tokens you can use instead of %H or in addition to it. See the nsswitch.conf syntax description in the Cygwin User Guide for details.

对于windows选项,还有一些其他的替代方案,还有一些其他的%令牌,您可以使用它们,而不是%H或者是它。看到nsswitch。conf的语法描述在Cygwin用户指南中的详细信息。

If you installed Cygwin prior to 1.7.34 or have run its mkpasswd utility so that you have an /etc/passwd file, you can change your Cygwin home directory by editing your user's entry in that file. Your home directory is the second-to-last element on your user's line in /etc/passwd

如果您在1.7.34之前安装了Cygwin,或者运行了它的mkpasswd实用程序,这样您就有了一个/etc/passwd文件,您可以通过编辑用户在该文件中的条目来更改Cygwin主目录。您的主目录是倒数第二个元素在/ etc / passwd。¹用户的线

Whichever way you do it, this causes the HOME environment variable to be set during shell startup.²

不管你做这件事,这使家庭环境变量被设置在shell启动,²

See this FAQ item for more on the topic.

有关这个主题的更多信息,请参见此常见问题。


Footnotes:

脚注:

  1. Consider moving /etc/passwd and /etc/group out of the way in order to use the new SAM/AD-based mechanism instead.

    考虑移动/etc/passwd和/etc/group,以便使用新的基于SAM/ ad的机制。

  2. While it is possible to simply set %HOME% via the Control Panel, it is officially discouraged. Not only does it unceremoniously override the above mechanisms, it doesn't always work, such as when running shell scripts via cron.

    虽然可以通过控制面板简单地设置%HOME%,但是它被官方禁止了。它不仅随意地覆盖上面的机制,它也不总是有效,比如通过cron运行shell脚本。

#2


65  

Cygwin 1.7.34+

For those using Cygwin 1.7.34 or higher Cygwin supports configuring how to fetch home directory, login shell, and gecos information in /etc/nsswitch.conf. This is detailed in the Cygwin User Guide section:

对于那些使用Cygwin 1.7.34或更高的Cygwin的人来说,他们支持配置如何在/etc/ nss. conf中获取主目录、登录shell和gecos信息。这是在Cygwin用户指南部分的详细内容:

If you've previously created an /etc/passwd or /etc/group file you'll want to remove those and configure Cygwin using the new Windows Security model to POSIX mappings.

如果您之前已经创建了/etc/passwd或/etc/group文件,那么您将希望删除它们,并使用新的Windows安全模型将Cygwin配置为POSIX映射。

[[ -f /etc/passwd ]] && mv /etc/passwd /etc/passwd.bak
[[ -f /etc/group ]] && mv /etc/group /etc/group.bak

The /etc/nsswitch.conf file's db_home: setting defines how Cygwin fetches the user's home directory. The default setting for db_home: is

的/etc/nsswitch.conf文件的db_home:设置定义了Cygwin如何获取用户的主目录。db_home的默认设置:is。

db_home: /home/%U

So by default, Cygwin just sets the home dir to /home/$USERNAME. You can change that though to point at any other custom path you want. The supported wildcard characters are:

因此,默认情况下,Cygwin只将home目录设置为/home/$用户名。您可以在任何其他定制路径上进行更改。支持的通配符是:

  • %u The Cygwin username (that's lowercase u).
  • Cygwin用户名(小写u)。
  • %U The Windows username (that's uppercase U).
  • %U Windows用户名(大写U)。
  • %D Windows domain in NetBIOS style.
  • %D Windows域的NetBIOS风格。
  • %H Windows home directory in POSIX style. Note that, for the db_home: setting, this only makes sense right after the preceeding slash, as in db_home: /%H/cygwin
  • %H Windows主目录的POSIX风格。注意,对于db_home:设置,这只在前面的斜杠之后才有意义,比如在db_home: /%H/cygwin。
  • %_ Since space and TAB characters are used to separate the schemata, a space in the filename has to be given as %_ (that's an underscore).
  • %_因为空格和制表符是用来分隔图式的,所以文件名中的空格必须是%_(这是下划线)。
  • %% A per-cent character.
  • % %另外的字符。

In place of a path, you can specify one of four named path schemata that are predefined.

为了替代路径,您可以指定一个预定义的四种命名路径模式之一。

  1. windows The user's home directory is set to the same directory which is used as Windows home directory, typically something along the lines of %USERPROFILE% or C:\Users\$USERNAME. Of course, the Windows directory is converted to POSIX-style by Cygwin.

    windows用户的主目录被设置为与windows主目录相同的目录,通常是在%USERPROFILE%或c:users\ $USERNAME的行中。当然,Windows目录被Cygwin转换为posix风格。

  2. cygwin AD only: The user's home directory is set to the POSIX path given in the cygwinHome attribute from the cygwinUser auxiliary class. See also the section called “The cygwin schema”.

    cygwin广告:用户的主目录被设置为cygwinHome属性从cygwinUser辅助类中给出的POSIX路径。参见“cygwin模式”一节。

  3. unix AD only: The user's home directory is set to the POSIX path given in the unixHomeDirectory attribute from the posixAccount auxiliary class. See also the section called “The unix schema”.

    unix AD only:用户的主目录被设置为来自posixAccount辅助类的unixHomeDirectory属性中给定的POSIX路径。参见“unix模式”一节。

  4. desc The user's home directory is set to the POSIX path given in the home="..." XML-alike setting in the user's description attribute in SAM or AD. See the section called “The desc schema” for a detailed description.

    desc将用户的主目录设置为home="…"中的POSIX路径。在SAM或AD中用户描述属性中的xml相似设置。请参见“desc模式”一节详细描述。

The following will make the user's home directory in Cygwin the same as is used for the Windows home directory.

下面将使Cygwin中的用户的主目录与Windows主目录相同。

db_home: windows

Cygwin 1.7.33 or earlier

For those using Cygwin 1.7.33 or earlier, update to the latest version Cygwin and remove previously used /etc/passwd and /etc/group files, then see the steps above.

对于使用Cygwin 1.7.33或更早的版本,更新最新版本的Cygwin并删除先前使用的/etc/passwd和/etc/group文件,然后查看上面的步骤。

Else, follow these older steps below.

另外,遵循下面这些较老的步骤。

Firstly, set a Windows environment variable for HOME that points to your user profile:

首先,为HOME设置一个Windows环境变量,该变量指向您的用户配置文件:

  1. Open System on the Control Panel
  2. 在控制面板上打开系统。
  3. On the Advanced tab click Environment Variables (toward the bottom)
  4. 在高级选项卡上单击环境变量(向底部)
  5. In the User Variables area click "New…"
  6. 在用户变量区域,点击“New…”
  7. For Variable name enter HOME
  8. 变量名输入HOME。
  9. For Variable value enter %USERPROFILE%
  10. 对于变量值输入%USERPROFILE%。
  11. Click OK in all the open dialog boxes to apply this new setting
  12. 在所有打开的对话框中单击OK以应用此新设置。

Now we are going to update the Cygwin /etc/passwd file with the Windows %HOME% variable we just created. Shell logins and remote logins via ssh will rely on /etc/passwd to tell them the location of the user's $HOME path.

现在我们将更新Cygwin /etc/passwd文件,其中包含我们刚刚创建的Windows %HOME%变量。通过ssh的Shell登录和远程登录将依赖/etc/passwd告诉他们用户的$HOME路径的位置。

At the Cygwin bash command prompt type the following:

在Cygwin bash命令提示符类型如下:

cp /etc/passwd /etc/passwd.bak
mkpasswd -l -p $(cygpath -H)  > /etc/passwd 
mkpasswd -d -p $(cygpath -H)  >> /etc/passwd 

The -d switch tells mkpasswd to include DOMAIN users, while -l is to only output LOCAL machine users. This is important if you're using a PC at work where the user information is obtained from a Windows Domain Controller.

d开关告诉mkpasswd包含域用户,而-l则只输出本地机器用户。如果您在工作中使用PC,而用户信息是从Windows域控制器获得的,那么这一点非常重要。

Now, you can also do the same for groups, though this is not necessary unless you will be using a computer that is part of a Windows Domain. Cygwin reads group information from the Windows account databases, but you can add an /etc/group file if your machine is often disconnected from its Domain Controller.

现在,您也可以对组进行同样的操作,尽管这是不必要的,除非您使用的是Windows域的一部分的计算机。Cygwin从Windows帐户数据库读取组信息,但如果您的机器经常与域控制器断开连接,则可以添加/etc/group文件。

At the Cygwin bash prompt type the following:

在Cygwin bash提示类型如下:

cp /etc/group /etc/group.bak
mkgroup -l > /etc/group 
mkgroup -d >> /etc/group 

Now, exit Cygwin and start it up again. You should find that your HOME path points to the same location as your Windows User Profile -- i.e. /cygdrive/c/Users/username

现在,退出Cygwin,重新开始。您应该发现您的HOME路径指向与您的Windows用户配置文件相同的位置,即/cygdrive/c/Users/username。

#3


28  

I did something quite simple. I did not want to change the windows 7 environment variable. So I directly edited the Cygwin.bat file.

我做了一些很简单的事情。我不想改变windows 7环境变量。所以我直接编辑了Cygwin。bat文件。

@echo off
SETLOCAL
set HOME=C:\path\to\home
C:
chdir C:\apps\cygwin\bin
bash --login -i
ENDLOCAL

This just starts the local shell with this home directory; that is what I wanted. I am not going to remotely access this, so this worked for me.

这仅仅是用这个主目录启动本地shell;这就是我想要的。我不会远程访问这个,所以这对我很有效。

#4


17  

Cygwin mount now support bind method which lets you mount a directory. Hence you can simply add the following line to /etc/fstab, then restart your shell:

Cygwin mount现在支持绑定方法,它允许您挂载一个目录。因此,只需将以下行添加到/etc/fstab,然后重新启动shell:

c:/Users /home none bind 0 0

#5


9  

Change your HOME environment variable.

更改您的家庭环境变量。

on XP, its right-click My Computer >> Properties >> Advanced >> Environment Variables >> User Variables for >> [select variable HOME] >> edit

在XP上,它的右击我的电脑>>的>>高级>>环境变量>>用户变量>> [select variable HOME] >0 >1编辑。

#6


6  

I'd like to add a correction/update to the bit about $HOME taking precedence. The home directory in /etc/passwd takes precedence over everything.

我想对有关$HOME的部分进行更正/更新。/etc/passwd中的主目录优先于所有内容。

I'm a long time Cygwin user and I just did a clean install of Windows 7 x64 and Cygwin V1.126. I was going nuts trying to figure out why every time I ran ssh I kept getting:

我是一个很长时间的Cygwin用户,我刚刚做了一个干净的安装Windows 7 x64和Cygwin V1.126。我疯了,想弄明白为什么每次我跑到宋承宪的时候,我总能得到:

e:\>ssh foo.bar.com
Could not create directory '/home/dhaynes/.ssh'.
The authenticity of host 'foo.bar.com (10.66.19.19)' can't be established.
...

I add the HOME=c:\users\dhaynes definition in the Windows environment but still it kept trying to create '/home/dhaynes'. I tried every combo I could including setting HOME to /cygdrive/c/users/dhaynes. Googled for the error message, could not find anything, couldn't find anything on the cygwin site. I use cygwin from cmd.exe, not bash.exe but the problem was present in both.

我在Windows环境中添加了HOME=c:\用户\dhaynes定义,但它仍然在尝试创建“/ HOME /dhaynes”。我试过了所有的组合,包括设置HOME to /cygdrive/c/user /dhaynes。谷歌搜索错误信息,找不到任何东西,在cygwin网站上找不到任何东西。我用的是cmd的cygwin。exe,不是bash。exe但问题在两者中都存在。

I finally realized that the home directory in /etc/passwd was taking precedence over the $HOME environment variable. I simple re-ran 'mkpasswd -l >/etc/passwd' and that updated the home directory, now all is well with ssh.

最后,我意识到/etc/passwd中的主目录优先于$ home环境变量。我简单地重新运行了“mkpasswd -l >/etc/passwd”,并且更新了主目录,现在一切都很好。

That may be obvious to linux types with sysadmin experience but for those of us who primarily use Windows it's a bit obscure.

对于使用sysadmin经验的linux类型来说,这可能是显而易见的,但是对于我们这些主要使用Windows的人来说,这有点晦涩。

#7


2  

I happen to use cwRsync (Cygwin + Rsync for Windows) where cygwin comes bundled, and I couldnt find /etc/passwd.

我碰巧使用cwRsync (Cygwin + Rsync for Windows), Cygwin是捆绑在一起的,我无法找到/etc/passwd。

And it kept saying

它不停地说

Could not create directory '/home/username/.ssh'.
...
Failed to add the host to the list of known hosts (/home/username/.ssh/known_hosts).

So I wrote a batch file which changed HOME variable before running rsync. Something like:

因此,我编写了一个批处理文件,它在运行rsync之前更改了HOME变量。喜欢的东西:

set HOME=.
rsync /path1 user@host:/path2

And viola! .ssh folder appeared in current working dir and rsync stopped annoying with rsa fingerprints.

和中提琴!.ssh文件夹出现在当前工作目录中,rsync停止使用rsa指纹。

It's a quick hotfix, but later you should change HOME to a more secure location.

这是一个快速的热修复程序,但是稍后您应该将其更改为更安全的位置。

#1


145  

Starting with Cygwin 1.7.34, the recommended way to do this is to add a custom db_home setting to /etc/nsswitch.conf. A common wish when doing this is to make your Cygwin home directory equal to your Windows user profile directory. This setting will do that:

从Cygwin 1.7.34开始,推荐的方法是将自定义db_home设置添加到/etc/nsswitch.conf。这样做的一个常见愿望是使您的Cygwin主目录与您的Windows用户配置文件目录相同。这个设置将会这样做:

db_home: windows

Or, equivalently:

或者,相当于:

db_home: /%H

You need to use the latter form if you want some variation on this scheme, such as to segregate your Cygwin home files into a subdirectory of your Windows user profile directory:

您需要使用后一种形式,如果您想对该方案进行一些更改,比如将Cygwin home文件隔离到Windows用户配置文件目录的子目录中:

db_home: /%H/cygwin

There are several other alternative schemes for the windows option plus several other % tokens you can use instead of %H or in addition to it. See the nsswitch.conf syntax description in the Cygwin User Guide for details.

对于windows选项,还有一些其他的替代方案,还有一些其他的%令牌,您可以使用它们,而不是%H或者是它。看到nsswitch。conf的语法描述在Cygwin用户指南中的详细信息。

If you installed Cygwin prior to 1.7.34 or have run its mkpasswd utility so that you have an /etc/passwd file, you can change your Cygwin home directory by editing your user's entry in that file. Your home directory is the second-to-last element on your user's line in /etc/passwd

如果您在1.7.34之前安装了Cygwin,或者运行了它的mkpasswd实用程序,这样您就有了一个/etc/passwd文件,您可以通过编辑用户在该文件中的条目来更改Cygwin主目录。您的主目录是倒数第二个元素在/ etc / passwd。¹用户的线

Whichever way you do it, this causes the HOME environment variable to be set during shell startup.²

不管你做这件事,这使家庭环境变量被设置在shell启动,²

See this FAQ item for more on the topic.

有关这个主题的更多信息,请参见此常见问题。


Footnotes:

脚注:

  1. Consider moving /etc/passwd and /etc/group out of the way in order to use the new SAM/AD-based mechanism instead.

    考虑移动/etc/passwd和/etc/group,以便使用新的基于SAM/ ad的机制。

  2. While it is possible to simply set %HOME% via the Control Panel, it is officially discouraged. Not only does it unceremoniously override the above mechanisms, it doesn't always work, such as when running shell scripts via cron.

    虽然可以通过控制面板简单地设置%HOME%,但是它被官方禁止了。它不仅随意地覆盖上面的机制,它也不总是有效,比如通过cron运行shell脚本。

#2


65  

Cygwin 1.7.34+

For those using Cygwin 1.7.34 or higher Cygwin supports configuring how to fetch home directory, login shell, and gecos information in /etc/nsswitch.conf. This is detailed in the Cygwin User Guide section:

对于那些使用Cygwin 1.7.34或更高的Cygwin的人来说,他们支持配置如何在/etc/ nss. conf中获取主目录、登录shell和gecos信息。这是在Cygwin用户指南部分的详细内容:

If you've previously created an /etc/passwd or /etc/group file you'll want to remove those and configure Cygwin using the new Windows Security model to POSIX mappings.

如果您之前已经创建了/etc/passwd或/etc/group文件,那么您将希望删除它们,并使用新的Windows安全模型将Cygwin配置为POSIX映射。

[[ -f /etc/passwd ]] && mv /etc/passwd /etc/passwd.bak
[[ -f /etc/group ]] && mv /etc/group /etc/group.bak

The /etc/nsswitch.conf file's db_home: setting defines how Cygwin fetches the user's home directory. The default setting for db_home: is

的/etc/nsswitch.conf文件的db_home:设置定义了Cygwin如何获取用户的主目录。db_home的默认设置:is。

db_home: /home/%U

So by default, Cygwin just sets the home dir to /home/$USERNAME. You can change that though to point at any other custom path you want. The supported wildcard characters are:

因此,默认情况下,Cygwin只将home目录设置为/home/$用户名。您可以在任何其他定制路径上进行更改。支持的通配符是:

  • %u The Cygwin username (that's lowercase u).
  • Cygwin用户名(小写u)。
  • %U The Windows username (that's uppercase U).
  • %U Windows用户名(大写U)。
  • %D Windows domain in NetBIOS style.
  • %D Windows域的NetBIOS风格。
  • %H Windows home directory in POSIX style. Note that, for the db_home: setting, this only makes sense right after the preceeding slash, as in db_home: /%H/cygwin
  • %H Windows主目录的POSIX风格。注意,对于db_home:设置,这只在前面的斜杠之后才有意义,比如在db_home: /%H/cygwin。
  • %_ Since space and TAB characters are used to separate the schemata, a space in the filename has to be given as %_ (that's an underscore).
  • %_因为空格和制表符是用来分隔图式的,所以文件名中的空格必须是%_(这是下划线)。
  • %% A per-cent character.
  • % %另外的字符。

In place of a path, you can specify one of four named path schemata that are predefined.

为了替代路径,您可以指定一个预定义的四种命名路径模式之一。

  1. windows The user's home directory is set to the same directory which is used as Windows home directory, typically something along the lines of %USERPROFILE% or C:\Users\$USERNAME. Of course, the Windows directory is converted to POSIX-style by Cygwin.

    windows用户的主目录被设置为与windows主目录相同的目录,通常是在%USERPROFILE%或c:users\ $USERNAME的行中。当然,Windows目录被Cygwin转换为posix风格。

  2. cygwin AD only: The user's home directory is set to the POSIX path given in the cygwinHome attribute from the cygwinUser auxiliary class. See also the section called “The cygwin schema”.

    cygwin广告:用户的主目录被设置为cygwinHome属性从cygwinUser辅助类中给出的POSIX路径。参见“cygwin模式”一节。

  3. unix AD only: The user's home directory is set to the POSIX path given in the unixHomeDirectory attribute from the posixAccount auxiliary class. See also the section called “The unix schema”.

    unix AD only:用户的主目录被设置为来自posixAccount辅助类的unixHomeDirectory属性中给定的POSIX路径。参见“unix模式”一节。

  4. desc The user's home directory is set to the POSIX path given in the home="..." XML-alike setting in the user's description attribute in SAM or AD. See the section called “The desc schema” for a detailed description.

    desc将用户的主目录设置为home="…"中的POSIX路径。在SAM或AD中用户描述属性中的xml相似设置。请参见“desc模式”一节详细描述。

The following will make the user's home directory in Cygwin the same as is used for the Windows home directory.

下面将使Cygwin中的用户的主目录与Windows主目录相同。

db_home: windows

Cygwin 1.7.33 or earlier

For those using Cygwin 1.7.33 or earlier, update to the latest version Cygwin and remove previously used /etc/passwd and /etc/group files, then see the steps above.

对于使用Cygwin 1.7.33或更早的版本,更新最新版本的Cygwin并删除先前使用的/etc/passwd和/etc/group文件,然后查看上面的步骤。

Else, follow these older steps below.

另外,遵循下面这些较老的步骤。

Firstly, set a Windows environment variable for HOME that points to your user profile:

首先,为HOME设置一个Windows环境变量,该变量指向您的用户配置文件:

  1. Open System on the Control Panel
  2. 在控制面板上打开系统。
  3. On the Advanced tab click Environment Variables (toward the bottom)
  4. 在高级选项卡上单击环境变量(向底部)
  5. In the User Variables area click "New…"
  6. 在用户变量区域,点击“New…”
  7. For Variable name enter HOME
  8. 变量名输入HOME。
  9. For Variable value enter %USERPROFILE%
  10. 对于变量值输入%USERPROFILE%。
  11. Click OK in all the open dialog boxes to apply this new setting
  12. 在所有打开的对话框中单击OK以应用此新设置。

Now we are going to update the Cygwin /etc/passwd file with the Windows %HOME% variable we just created. Shell logins and remote logins via ssh will rely on /etc/passwd to tell them the location of the user's $HOME path.

现在我们将更新Cygwin /etc/passwd文件,其中包含我们刚刚创建的Windows %HOME%变量。通过ssh的Shell登录和远程登录将依赖/etc/passwd告诉他们用户的$HOME路径的位置。

At the Cygwin bash command prompt type the following:

在Cygwin bash命令提示符类型如下:

cp /etc/passwd /etc/passwd.bak
mkpasswd -l -p $(cygpath -H)  > /etc/passwd 
mkpasswd -d -p $(cygpath -H)  >> /etc/passwd 

The -d switch tells mkpasswd to include DOMAIN users, while -l is to only output LOCAL machine users. This is important if you're using a PC at work where the user information is obtained from a Windows Domain Controller.

d开关告诉mkpasswd包含域用户,而-l则只输出本地机器用户。如果您在工作中使用PC,而用户信息是从Windows域控制器获得的,那么这一点非常重要。

Now, you can also do the same for groups, though this is not necessary unless you will be using a computer that is part of a Windows Domain. Cygwin reads group information from the Windows account databases, but you can add an /etc/group file if your machine is often disconnected from its Domain Controller.

现在,您也可以对组进行同样的操作,尽管这是不必要的,除非您使用的是Windows域的一部分的计算机。Cygwin从Windows帐户数据库读取组信息,但如果您的机器经常与域控制器断开连接,则可以添加/etc/group文件。

At the Cygwin bash prompt type the following:

在Cygwin bash提示类型如下:

cp /etc/group /etc/group.bak
mkgroup -l > /etc/group 
mkgroup -d >> /etc/group 

Now, exit Cygwin and start it up again. You should find that your HOME path points to the same location as your Windows User Profile -- i.e. /cygdrive/c/Users/username

现在,退出Cygwin,重新开始。您应该发现您的HOME路径指向与您的Windows用户配置文件相同的位置,即/cygdrive/c/Users/username。

#3


28  

I did something quite simple. I did not want to change the windows 7 environment variable. So I directly edited the Cygwin.bat file.

我做了一些很简单的事情。我不想改变windows 7环境变量。所以我直接编辑了Cygwin。bat文件。

@echo off
SETLOCAL
set HOME=C:\path\to\home
C:
chdir C:\apps\cygwin\bin
bash --login -i
ENDLOCAL

This just starts the local shell with this home directory; that is what I wanted. I am not going to remotely access this, so this worked for me.

这仅仅是用这个主目录启动本地shell;这就是我想要的。我不会远程访问这个,所以这对我很有效。

#4


17  

Cygwin mount now support bind method which lets you mount a directory. Hence you can simply add the following line to /etc/fstab, then restart your shell:

Cygwin mount现在支持绑定方法,它允许您挂载一个目录。因此,只需将以下行添加到/etc/fstab,然后重新启动shell:

c:/Users /home none bind 0 0

#5


9  

Change your HOME environment variable.

更改您的家庭环境变量。

on XP, its right-click My Computer >> Properties >> Advanced >> Environment Variables >> User Variables for >> [select variable HOME] >> edit

在XP上,它的右击我的电脑>>的>>高级>>环境变量>>用户变量>> [select variable HOME] >0 >1编辑。

#6


6  

I'd like to add a correction/update to the bit about $HOME taking precedence. The home directory in /etc/passwd takes precedence over everything.

我想对有关$HOME的部分进行更正/更新。/etc/passwd中的主目录优先于所有内容。

I'm a long time Cygwin user and I just did a clean install of Windows 7 x64 and Cygwin V1.126. I was going nuts trying to figure out why every time I ran ssh I kept getting:

我是一个很长时间的Cygwin用户,我刚刚做了一个干净的安装Windows 7 x64和Cygwin V1.126。我疯了,想弄明白为什么每次我跑到宋承宪的时候,我总能得到:

e:\>ssh foo.bar.com
Could not create directory '/home/dhaynes/.ssh'.
The authenticity of host 'foo.bar.com (10.66.19.19)' can't be established.
...

I add the HOME=c:\users\dhaynes definition in the Windows environment but still it kept trying to create '/home/dhaynes'. I tried every combo I could including setting HOME to /cygdrive/c/users/dhaynes. Googled for the error message, could not find anything, couldn't find anything on the cygwin site. I use cygwin from cmd.exe, not bash.exe but the problem was present in both.

我在Windows环境中添加了HOME=c:\用户\dhaynes定义,但它仍然在尝试创建“/ HOME /dhaynes”。我试过了所有的组合,包括设置HOME to /cygdrive/c/user /dhaynes。谷歌搜索错误信息,找不到任何东西,在cygwin网站上找不到任何东西。我用的是cmd的cygwin。exe,不是bash。exe但问题在两者中都存在。

I finally realized that the home directory in /etc/passwd was taking precedence over the $HOME environment variable. I simple re-ran 'mkpasswd -l >/etc/passwd' and that updated the home directory, now all is well with ssh.

最后,我意识到/etc/passwd中的主目录优先于$ home环境变量。我简单地重新运行了“mkpasswd -l >/etc/passwd”,并且更新了主目录,现在一切都很好。

That may be obvious to linux types with sysadmin experience but for those of us who primarily use Windows it's a bit obscure.

对于使用sysadmin经验的linux类型来说,这可能是显而易见的,但是对于我们这些主要使用Windows的人来说,这有点晦涩。

#7


2  

I happen to use cwRsync (Cygwin + Rsync for Windows) where cygwin comes bundled, and I couldnt find /etc/passwd.

我碰巧使用cwRsync (Cygwin + Rsync for Windows), Cygwin是捆绑在一起的,我无法找到/etc/passwd。

And it kept saying

它不停地说

Could not create directory '/home/username/.ssh'.
...
Failed to add the host to the list of known hosts (/home/username/.ssh/known_hosts).

So I wrote a batch file which changed HOME variable before running rsync. Something like:

因此,我编写了一个批处理文件,它在运行rsync之前更改了HOME变量。喜欢的东西:

set HOME=.
rsync /path1 user@host:/path2

And viola! .ssh folder appeared in current working dir and rsync stopped annoying with rsa fingerprints.

和中提琴!.ssh文件夹出现在当前工作目录中,rsync停止使用rsa指纹。

It's a quick hotfix, but later you should change HOME to a more secure location.

这是一个快速的热修复程序,但是稍后您应该将其更改为更安全的位置。