在阅读了这里的精彩文章后得到了很多支持,我的第一个问题是:
我尝试在Mac和Windows 10(20H2(之间使用密钥设置ssh。到目前为止我所做的:
- 在Mac上生成密钥,测试了带有自动登录树莓的pub密钥,一切都很好
- 将pub密钥复制到win10,根据https://askme4tech.com/how-install-and-configure-open-ssh-server-windows-10
- 将sshd_config更改为
- 如果我尝试对win10进行ssh,我会得到(使用ssh-v((只有最后几行(:
...
debug1: Authentication succeeded (publickey).
Authenticated to 192.168.2.157 ([192.168.2.157]:22).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: pledge: network
client_loop: send disconnect: Broken pipe
如果我在Win10上停止sshd并将其作为服务启动,只需
c:>sshd.exe
一切正常。我在手动启动调试模式sshd-d时发现了这一点。由于我在Win10上的专业知识有限,我不知道在哪里查找或修复这个问题,所以感谢您的提示!
Manu
# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.
# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options override the
# default value.
#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
#HostKey __PROGRAMDATA__/ssh/ssh_host_rsa_key
#HostKey __PROGRAMDATA__/ssh/ssh_host_dsa_key
#HostKey __PROGRAMDATA__/ssh/ssh_host_ecdsa_key
#HostKey __PROGRAMDATA__/ssh/ssh_host_ed25519_key
# Ciphers and keying
#RekeyLimit default none
# Logging
#SyslogFacility AUTH
#LogLevel INFO
# Authentication:
#LoginGraceTime 2m
#PermitRootLogin prohibit-password
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
PubkeyAuthentication yes
# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile .ssh/authorized_keys
#AuthorizedPrincipalsFile none
# For this to work you will also need host keys in %programData%/ssh/ssh_known_hosts
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes
# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no
#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
#PermitTTY yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#PermitUserEnvironment no
ClientAliveInterval 60
#ClientAliveCountMax 3
#UseDNS no
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none
# no default banner path
#Banner none
# override default of no subsystems
Subsystem sftp sftp-server.exe
# Example of overriding settings on a per-user basis
#Match User anoncvs
# AllowTcpForwarding no
# PermitTTY no
# ForceCommand cvs server
#Match Group administrators
# AuthorizedKeysFile __PROGRAMDATA__/ssh/administrators_authorized_keys
如果我在Win10上停止sshd并将其作为服务启动,只需使用c:>sshd.exe
- 在一种情况下,sshd作为服务运行,可能使用LocalSystem帐户
- 在另一个命令行中,您以您(您的Windows帐户(的身份运行sshd
环境将不一样,特别是对于";CCD_ 2";文件
如文档中所述:
在Windows中,默认情况下,
sshd
从%programdata%sshsshd_config
读取配置数据,或者可以通过使用-f
参数启动sshd.exe
来指定不同的配置文件
如果该文件不存在,sshd
会在服务启动时生成一个具有默认配置的文件。
将ssh守护进程作为Windows服务运行时激活日志,如下所示:
打开管理powershell提示符并运行:
notepad C:ProgramDatasshsshd_config
查找";CCD_ 8";部分,并添加这两行。
SyslogFacility LOCAL0 LogLevel DEBUG3
运行
services.msc
,如果服务正在运行,则重新启动服务;如果服务已停止,则启动服务
请确保将其设置为作为系统帐户运行。