[英]SSH from rsync on Windows
My build script uploads to production using rsync
via ssh
.我的构建脚本通过
ssh
使用rsync
上传到生产环境。 Normally, I deploy from a Linux box, but I want to be able to deploy from Windows, too, for those times when I need to make a quick change and only have access to my Windows machine.通常,我从 Linux 机器部署,但我也希望能够从 Windows 部署,以便我需要快速更改并且只能访问我的 Windows 机器。 However, I'm having trouble.
但是,我遇到了麻烦。 Here's the relevant part of the verbose output.
这是详细输出的相关部分。 The first line is printed by my build script, while the rest are printed by either rsync or programs it calls (ie, I don't call SSH directly).
第一行由我的构建脚本打印,其余由 rsync 或它调用的程序打印(即,我不直接调用 SSH)。
Executing the rsync command: ['rsync', '--verbose', '-avzihhhc', '--exclude=/.well-known', '--exclude', 'deploy.sh', '--delete', '..\\scottseverance.mss\\_site\\', 'myuser@myhost:/home/public']
opening connection using: ssh -l myuser myhost rsync --server -vvnlogDtprcze.iLsfxC "--log-
format=%i" --delete . /home/public (11 args)
Could not create directory '/home/Scott/.ssh'.
The authenticity of host 'myhost (host's ip address)' can't be established.
ECDSA key fingerprint is SHA256:a+Ny0PLkKhm80+5kqzqfVXIlbkQpn/CpMMrzurd8sDI.
Are you sure you want to continue connecting (yes/no)? yes
Failed to add the host to the list of known hosts (/home/Scott/.ssh/known_hosts).
myuser@myhost's password:
I think the key is what directories it's searching for.我认为关键是它要搜索的目录。 Notice that it can't create
/home/Scott/.ssh
.请注意,它无法创建
/home/Scott/.ssh
。 Naturally, it can't do this, since /home
doesn't exist on a Windows machine.自然,它不能这样做,因为
/home
在 Windows 机器上不存在。 $HOME
returns /c/Users/Scott
, so even if it's looking for UNIX-style variables, it shouldn't get confused. $HOME
返回/c/Users/Scott
,因此即使它正在寻找 UNIX 样式的变量,也不应该混淆。 In addition, the fact that it's asking for a password instead of using my key shows that my .ssh
directory isn't getting found.此外,它要求输入密码而不是使用我的密钥这一事实表明我的
.ssh
目录没有被找到。
Here's my setup.这是我的设置。
ssh
directly from the command line works as expected.ssh
按预期工作。rsync
.rsync
。 Any ideas what might be going on?任何想法可能会发生什么?
I found the answer in a comment posted on Chocolatey's rsync
page .我在Chocolatey 的
rsync
页面上发表的评论中找到了答案。 The issue is that choco
's rsync
inexplicably ships with a bundled SSH, and that ssh is broken.问题是
choco
的rsync
莫名其妙地附带了捆绑的 SSH,而 ssh 已损坏。 Of course, it doesn't make any sense to include SSH with rsync as they're two entirely separate programs.当然,将 SSH 包含在 rsync 中没有任何意义,因为它们是两个完全独立的程序。 I tried renaming the bundled SSH, but that didn't work.
我尝试重命名捆绑的 SSH,但这没有用。 The comment below did, however:
然而,下面的评论确实如此:
The user Adam wrote :用户亚当写道:
Kind of broken SSH!
有点坏的 SSH!
The ssh that comes with rsync is effectively not working because it looks for the user home directory in the wrong place.
rsync 附带的 ssh 实际上不起作用,因为它在错误的位置查找用户主目录。 You can fix this by creating
C:\\ProgramData\\chocolatey\\lib\\rsync\\cwRsync_5.5.0_x86_Free\\etc\\nsswitch.conf
containingdb_home: /%H
.您可以通过创建包含
db_home: /%H
C:\\ProgramData\\chocolatey\\lib\\rsync\\cwRsync_5.5.0_x86_Free\\etc\\nsswitch.conf
来解决此问题。 Would be nice to have the installer creating it.让安装程序创建它会很好。 But then when you use PubkeyAuthentication or a per user ssh config, it complains about too open permissions, which can be fixed by running
但是当您使用 PubkeyAuthentication 或每个用户的 ssh 配置时,它会抱怨过于开放的权限,这可以通过运行来修复
set key=".ssh\\id_rsa" icacls %key% /c /t /inheritance:d icacls %key% /c /t /grant %username%:F icacls %key% /c /t /remove Administrator BUILTIN\\Administrators BUILTIN Everyone System Users icacls %key%
The ssh from the
openssh
package does not have this problem.openssh
包中的 ssh 没有这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.