Sub*_*ash 3 windows ssh cygwin
我正在尝试从 Linux 服务器无需密码登录到 Windows。我已经从 GitHub 安装了 OpenSSH,并且可以执行scp和ssh. 我尝试将 复制authorized_keys到 Windows 位置。但它仍然无法正常工作。该功能应该是没有密码提示,用于从 linux 环境运行 ssh 或 scp 到登录/显示 windows 目录。
我尝试了以下命令:
cat .ssh/id_rsa.pub | ssh edh_win@xxx.xxx.xxx.xxx 'cat >> .ssh/authorized_keys'
ssh edh_win@xxx.xxx.xxx.xxx "chmod 700 .ssh; chmod 640 .ssh/authorized_keys"
Run Code Online (Sandbox Code Playgroud)
但得到错误无法理解cat和chmod。
更新错误
'cat' is not recognized as an internal or external command,
operable program or batch file.
'chmod' is not recognized as an internal or external command,
operable program or batch file.
Run Code Online (Sandbox Code Playgroud)
我需要安装cygwin吗?如果是,请帮助实施。
任何帮助表示赞赏。下面是错误的图像。
小智 6
在 Linux 之间建立无密码 SSH 的步骤?视窗:
笔记:
C:\Windows\System32\OpenSSH或C:\Program Files\OpenSSH到系统PathOpenSSH-Win64.zip)C:\Program Files\OpenSSH并进入目录按照安装 Wiki 中提到的步骤 4 - 6 进行操作:
# In an elevated Powershell console, run the following:
powershell -ExecutionPolicy Bypass -File install-sshd.ps1
# Open the firewall for sshd.exe to allow inbound SSH connections
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
# Start sshd (this will automatically generate host keys under %programdata%\ssh if they don't already exist)
net start sshd ; net start ssh-agent
Run Code Online (Sandbox Code Playgroud)执行以下命令,它应该显示Running两个服务的状态:
Set-Service ssh-agent -StartupType Automatic
Set-Service sshd -StartupType Automatic
Get-Service -Name ssh-agent,sshd
Run Code Online (Sandbox Code Playgroud)
如果没有运行:打开服务并启动OpenSSH Server和OpenSSH Authentication Agent
ssh-keygen并按照提示操作C:\ProgramData\ssh\administrators_authorized_keys:
New-Item -ItemType file "C:\ProgramData\ssh\administrators_authorized_keys"
Run Code Online (Sandbox Code Playgroud)/root/.ssh/id_rsa.pub到C:\ProgramData\ssh\administrators_authorized_keys
id_rsa.pub在 Linux 上不存在,请通过以下方式生成:ssh-keygenC:\Users\Administrator\.ssh\id_rsa.pub到/root/.ssh/authorized_keys
authorized_keys不存在:
touch "/root/.ssh/authorized_keys"
Run Code Online (Sandbox Code Playgroud)对于权限设置:
icacls "C:\ProgramData\ssh\administrators_authorized_keys" /remove "NT AUTHORITY\Authenticated Users"
icacls "C:\ProgramData\ssh\administrators_authorized_keys" /inheritance:r
Restart-Service -Name sshd, ssh-agent -Force
Run Code Online (Sandbox Code Playgroud)Windows 主机上的相关位置:
C:\Windows\Sytem32\OpenSSH\C:\Program Files\OpenSSH\C:\Users\Administrator\.ssh\C:\ProgramData\ssh\参考:
错误说明了一切。
或多或少,您的 ssh 服务器提供了……嗯,一个 ssh 服务器。默认情况下,它没有您尝试运行的“unix”样式或 linux coreutils。
虽然将此 ssh 服务器替换为 cygwin 可能会有所帮助 - 您实际上需要做的是了解您在做什么,而不是假设 linux 命令会起作用。
你可能可以在 Windows 上获取 cat - 通过它的各种本机包,例如与 git或GOW捆绑的包
权限模型的工作方式可能有所不同,因此您需要使用本机工具来完成此操作。
它需要一些阅读,但这表明“只有系统、管理员和所有者可以访问” - 并且这篇文章建议您可以使用它ICACLS来设置适当的权限。
结论是——你必须了解你的工具,并意识到你不会在任何地方都找到相同的环境。
| 归档时间: |
|
| 查看次数: |
11901 次 |
| 最近记录: |