Windows 10 のオプション機能セクションから OpenSSH サーバーとクライアントを正常にセットアップしました。
サーバーにログインしようとすると、パスワードの入力を求められます。Windows 10 PC には Microsoft アカウントのパスワードを 1 つだけ設定しています。しかし、そのパスワードではサーバーがアクセスを拒否します。SSH サーバーのパスワードはまだ設定していません。
サーバーのデフォルト パスワードは何ですか?
フォルダsshd_config
内のファイルの内容は次のとおりです:%PROGRAMDATA%\ssh\
# 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 0
#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
これは次の出力ですGet-NetFirewallRule -Name *ssh*
:
Name : OpenSSH-Server-In-TCP
DisplayName : OpenSSH SSH Server (sshd)
Description : Inbound rule for OpenSSH SSH Server (sshd)
DisplayGroup : OpenSSH Server
Group : OpenSSH Server
Enabled : True
Profile : Any
Platform : {}
Direction : Inbound
Action : Allow
EdgeTraversalPolicy : Block
LooseSourceMapping : False
LocalOnlyMapping : False
Owner :
PrimaryStatus : OK
Status : The rule was parsed successfully from the store. (65536)
EnforcementStatus : NotApplicable
PolicyStoreSource : PersistentStore
PolicyStoreSourceType : Local
Name : SshProxy-Service
DisplayName : SshProxy-Service-Private
Description : SSH Server Proxy Service
DisplayGroup : Ssh Server
Group : Ssh Server
Enabled : True
Profile : Private
Platform : {}
Direction : Inbound
Action : Allow
EdgeTraversalPolicy : Block
LooseSourceMapping : False
LocalOnlyMapping : False
Owner :
PrimaryStatus : OK
Status : The rule was parsed successfully from the store. (65536)
EnforcementStatus : NotApplicable
PolicyStoreSource : PersistentStore
PolicyStoreSourceType : Local
Name : SshProxy-Service-Domain
DisplayName : SshProxy-Service-Domain
Description : SSH Server Proxy Service
DisplayGroup : Ssh Server
Group : Ssh Server
Enabled : True
Profile : Domain
Platform : {}
Direction : Inbound
Action : Allow
EdgeTraversalPolicy : Block
LooseSourceMapping : False
LocalOnlyMapping : False
Owner :
PrimaryStatus : OK
Status : The rule was parsed successfully from the store. (65536)
EnforcementStatus : NotApplicable
PolicyStoreSource : PersistentStore
PolicyStoreSourceType : Local
出力[System.Security.Principal.WindowsIdentity]::GetCurrent().Name
:
<my_name>\USER
答え1
SSH サーバーのパスワードをまだ設定していません。サーバーのデフォルトのパスワードは何ですか?
ありません。
サーバーにログインしようとすると、必ずパスワードを求められます。Windows 10 PC には Microsoft アカウントのパスワードを 1 つだけ設定しています。しかし、サーバーはそのパスワードでのアクセスを拒否します。
間違ったユーザー名で接続しようとしています。ssh Machine_Name\Username@localhost
サーバーに接続するには を使用する必要があります。
なぜ \USER 部分を指定する必要があるのですか?
OpenSSH サーバーに接続するには、使用するユーザー名を明示的に指定する必要があります。また、 という構文を使用したことも示しています。ssh <my_name>@localhost
これは、ユーザー名が実際のユーザー名ではなく、マシンの名前であることを示しています。
以来<my_name>
マシン上の実際のユーザー名ではないため、パスワード認証が失敗しました。実際にはUsername
そしてそれがマシン上にあることを明示的に示すMachine_Name\Username
。
の出力は、[System.Security.Principal.WindowsIdentity]::GetCurrent().Name
何を使用すべきかを示します。
答え2
有効なユーザー名とパスワードが受け入れられないもう 1 つの理由は、設定されたシェルが間違っている場合です。
どれがどれか確認するには
reg query HKLM\SOFTWARE\OpenSSH /v DefaultShell
デフォルトのディレクトリにある場合は、Powershell に設定するには:
reg add HKLM\SOFTWARE\OpenSSH /v DefaultShell /d C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe
答え3
whoami
cmd に入力すると、テキストが表示されるので、そのテキスト全体をコピーします。全体とは、全体を意味します。この例では、nick\hp
出力として取得したとします。次に、cmd で と入力し
ssh nick\hp@localhost
、Enter キーを押します。パスワードを要求されますので、ここで Microsoft アカウントのパスワードを入力してください。すると、正常に SSH 接続できるようになります。
答え4
私も同様の問題を抱えていました。ある日まで、ssh ログインは正常に動作していました。何が起こったのか正確にはわかりません。おそらく、samba 経由で Windows フォルダーを共有しようとして、openssh の設定を台無しにしたのでしょう。とにかく、解決策は次のとおりです。
新しいWindowsユーザーを作成する
これで完了です。新しいアカウントで正常にログインできます。古いアカウントの SSH パスワードは何もしていないのに、変更されたようです。