Mailing List Archive

ssh from linux to Windows
I installed openssh server on Windows 11 and tried to ssh to it using the id_rsa.pub key
but I didn't have luck.  I copied the key to .ssh\authorized_keys file.
On linux the last line ending with "\"  on Windows Notepad replaces it with the "+" sign.

ssh with password is working  but windows doesn't recognize the public key or maybe it is wrong directory  C:\Users\Garry Server\.ssh\authorized_keys

--
Thelma
Re: ssh from linux to Windows [ In reply to ]
On 1/6/24 20:09, thelma@sys-concept.com wrote:
> I installed openssh server on Windows 11 and tried to ssh to it using the id_rsa.pub key
> but I didn't have luck.  I copied the key to .ssh\authorized_keys file.
> On linux the last line ending with "\"  on Windows Notepad replaces it with the "+" sign.
>
> ssh with password is working  but windows doesn't recognize the public key or maybe it is wrong directory  C:\Users\Garry Server\.ssh\authorized_keys

Trying to run: "ssh -vv" I get:

debug1: Authenticating to 10.0.0.130:22 as 'Glen Server'
debug1: load_hostkeys: fopen /home/joseph/.ssh/known_hosts2: No such file or directory

Where is it taking the : "known_hosts2" in home directory .ssh/ I only have file "known_hosts"
In /etc/ssh/sshd_config (computer ssh is initiated from) I can not find any reference to "known_hosts2"

Nor, windows \ProgramData\ssh\sshd_config contain any reference to "known_hosts2"
Re: ssh from linux to Windows [ In reply to ]
On 2024-01-08, thelma@sys-concept.com wrote:

> On 1/6/24 20:09, thelma@sys-concept.com wrote:
>> I installed openssh server on Windows 11 and tried to ssh to it
>> using the id_rsa.pub key
>> but I didn't have luck.  I copied the key to .ssh\authorized_keys file.
>> On linux the last line ending with "\"  on Windows Notepad replaces
>> it with the "+" sign.
>>
>> ssh with password is working  but windows doesn't recognize the
>> public key or maybe it is wrong directory  C:\Users\Garry
>> Server\.ssh\authorized_keys
>
> Trying to run: "ssh -vv" I get:
>
> debug1: Authenticating to 10.0.0.130:22 as 'Glen Server'
> debug1: load_hostkeys: fopen /home/joseph/.ssh/known_hosts2: No such
> file or directory
>
> Where is it taking the : "known_hosts2" in home directory .ssh/ I only
> have file "known_hosts"
> In /etc/ssh/sshd_config (computer ssh is initiated from) I can not
> find any reference to "known_hosts2"
>
> Nor, windows \ProgramData\ssh\sshd_config contain any reference to
> "known_hosts2"

I think the file to check would be ssh_config on the client side, not
sshd_config. But it's possible it's not mentioned there either, as it
seems to be part of the default at least in some systems, see for
example

https://serverfault.com/questions/1091575/why-does-ssh-think-i-still-have-a-known-hosts2-file

This is just the usual approach of a user-specific file not existing
unless it is created. I'd say you can just ignore this message and focus
on the verbose messages about the authentication mechanisms.

--
Nuno Silva
Re: ssh from linux to Windows [ In reply to ]
looking for known_hosts2 (and also /etc/ssh/ssh_known_hosts and /etc/ssh/ssh_known_hosts2)  also happens on my machines, both a debian install and my gentoo machine, the files not being present does not prevent the ssh connection from working though. So this is probably not the issue.

Judging from comments [1] it appears to be an undocumented legacy feature.

[1] https://github.com/search?q=repo%3Aopenssh%2Fopenssh-portable+known_hosts2&type=commits

On 08.01.24 01:32, thelma@sys-concept.com wrote:
> On 1/6/24 20:09, thelma@sys-concept.com wrote:
>> I installed openssh server on Windows 11 and tried to ssh to it using the id_rsa.pub key
>> but I didn't have luck.  I copied the key to .ssh\authorized_keys file.
>> On linux the last line ending with "\"  on Windows Notepad replaces it with the "+" sign.
>>
>> ssh with password is working  but windows doesn't recognize the public key or maybe it is wrong directory  C:\Users\Garry Server\.ssh\authorized_keys
>
> Trying to run: "ssh -vv" I get:
>
> debug1: Authenticating to 10.0.0.130:22 as 'Glen Server'
> debug1: load_hostkeys: fopen /home/joseph/.ssh/known_hosts2: No such file or directory
>
> Where is it taking the : "known_hosts2" in home directory .ssh/ I only have file "known_hosts"
> In /etc/ssh/sshd_config (computer ssh is initiated from) I can not find any reference to "known_hosts2"
>
> Nor, windows \ProgramData\ssh\sshd_config contain any reference to "known_hosts2"
>
>
>
>
Re: Re: ssh from linux to Windows [ In reply to ]
On 1/8/24 01:41, Nuno Silva wrote:
> On 2024-01-08, thelma@sys-concept.com wrote:
>
>> On 1/6/24 20:09, thelma@sys-concept.com wrote:
>>> I installed openssh server on Windows 11 and tried to ssh to it
>>> using the id_rsa.pub key
>>> but I didn't have luck.  I copied the key to .ssh\authorized_keys file.
>>> On linux the last line ending with "\"  on Windows Notepad replaces
>>> it with the "+" sign.
>>>
>>> ssh with password is working  but windows doesn't recognize the
>>> public key or maybe it is wrong directory  C:\Users\Garry
>>> Server\.ssh\authorized_keys
>>
>> Trying to run: "ssh -vv" I get:
>>
>> debug1: Authenticating to 10.0.0.130:22 as 'Glen Server'
>> debug1: load_hostkeys: fopen /home/joseph/.ssh/known_hosts2: No such
>> file or directory
>>
>> Where is it taking the : "known_hosts2" in home directory .ssh/ I only
>> have file "known_hosts"
>> In /etc/ssh/sshd_config (computer ssh is initiated from) I can not
>> find any reference to "known_hosts2"
>>
>> Nor, windows \ProgramData\ssh\sshd_config contain any reference to
>> "known_hosts2"
>
> I think the file to check would be ssh_config on the client side, not
> sshd_config. But it's possible it's not mentioned there either, as it
> seems to be part of the default at least in some systems, see for
> example

The ssh_config on the client side id default, never changed anything in it.

> https://serverfault.com/questions/1091575/why-does-ssh-think-i-still-have-a-known-hosts2-file
>
> This is just the usual approach of a user-specific file not existing
> unless it is created. I'd say you can just ignore this message and focus
> on the verbose messages about the authentication mechanisms.

In the link above the suggest fix for "...fix $HOME/.ssh/known_hosts2: No such file or directory"
to add "UserKnownHostsFile ~/.ssh/known_hosts"
I tried to add it to sshd_config but ssh wouldn't even start.

The above error message it just might be the noise, linux to linux all connections work, it is just linux to windows it is not working.
Re: Re: ssh from linux to Windows [ In reply to ]
On Monday, 8 January 2024 13:45:16 GMT thelma@sys-concept.com wrote:
> On 1/8/24 01:41, Nuno Silva wrote:
> > On 2024-01-08, thelma@sys-concept.com wrote:
> >> On 1/6/24 20:09, thelma@sys-concept.com wrote:
> >>> I installed openssh server on Windows 11 and tried to ssh to it
> >>> using the id_rsa.pub key
> >>> but I didn't have luck. I copied the key to .ssh\authorized_keys file.
> >>> On linux the last line ending with "\" on Windows Notepad replaces
> >>> it with the "+" sign.
> >>>
> >>> ssh with password is working but windows doesn't recognize the
> >>> public key or maybe it is wrong directory C:\Users\Garry
> >>> Server\.ssh\authorized_keys
> >>
> >> Trying to run: "ssh -vv" I get:
> >>
> >> debug1: Authenticating to 10.0.0.130:22 as 'Glen Server'
> >> debug1: load_hostkeys: fopen /home/joseph/.ssh/known_hosts2: No such
> >> file or directory
> >>
> >> Where is it taking the : "known_hosts2" in home directory .ssh/ I only
> >> have file "known_hosts"
> >> In /etc/ssh/sshd_config (computer ssh is initiated from) I can not
> >> find any reference to "known_hosts2"
> >>
> >> Nor, windows \ProgramData\ssh\sshd_config contain any reference to
> >> "known_hosts2"
> >
> > I think the file to check would be ssh_config on the client side, not
> > sshd_config. But it's possible it's not mentioned there either, as it
> > seems to be part of the default at least in some systems, see for
> > example
>
> The ssh_config on the client side id default, never changed anything in it.
>
> > https://serverfault.com/questions/1091575/why-does-ssh-think-i-still-have-> > a-known-hosts2-file
> >
> > This is just the usual approach of a user-specific file not existing
> > unless it is created. I'd say you can just ignore this message and focus
> > on the verbose messages about the authentication mechanisms.
>
> In the link above the suggest fix for "...fix $HOME/.ssh/known_hosts2: No
> such file or directory" to add "UserKnownHostsFile ~/.ssh/known_hosts"
> I tried to add it to sshd_config but ssh wouldn't even start.
>
> The above error message it just might be the noise, linux to linux all
> connections work, it is just linux to windows it is not working.

The known_hosts and known_hosts2 messages you saw in your client are NOT the
cause of your problem. If you must set your own default known_hosts file,
then launch your ssh client like this:

ssh -o GlobalKnownHostsFile=~/.ssh/My_own_known_hosts <user_name>@<IP_address>
Re: ssh from linux to Windows [ In reply to ]
On 2024-01-08, thelma@sys-concept.com wrote:

> On 1/8/24 01:41, Nuno Silva wrote:
>> On 2024-01-08, thelma@sys-concept.com wrote:
>>
>>> On 1/6/24 20:09, thelma@sys-concept.com wrote:
>>>> I installed openssh server on Windows 11 and tried to ssh to it
>>>> using the id_rsa.pub key
>>>> but I didn't have luck.  I copied the key to .ssh\authorized_keys file.
>>>> On linux the last line ending with "\"  on Windows Notepad replaces
>>>> it with the "+" sign.
>>>>
>>>> ssh with password is working  but windows doesn't recognize the
>>>> public key or maybe it is wrong directory  C:\Users\Garry
>>>> Server\.ssh\authorized_keys
>>>
>>> Trying to run: "ssh -vv" I get:
>>>
>>> debug1: Authenticating to 10.0.0.130:22 as 'Glen Server'
>>> debug1: load_hostkeys: fopen /home/joseph/.ssh/known_hosts2: No such
>>> file or directory
>>>
>>> Where is it taking the : "known_hosts2" in home directory .ssh/ I only
>>> have file "known_hosts"
>>> In /etc/ssh/sshd_config (computer ssh is initiated from) I can not
>>> find any reference to "known_hosts2"
>>>
>>> Nor, windows \ProgramData\ssh\sshd_config contain any reference to
>>> "known_hosts2"
>>
>> I think the file to check would be ssh_config on the client side, not
>> sshd_config. But it's possible it's not mentioned there either, as it
>> seems to be part of the default at least in some systems, see for
>> example
>
> The ssh_config on the client side id default, never changed anything in it.
>
>> https://serverfault.com/questions/1091575/why-does-ssh-think-i-still-have-a-known-hosts2-file
>>
>> This is just the usual approach of a user-specific file not existing
>> unless it is created. I'd say you can just ignore this message and focus
>> on the verbose messages about the authentication mechanisms.
>
> In the link above the suggest fix for "...fix $HOME/.ssh/known_hosts2:
> No such file or directory"
> to add "UserKnownHostsFile ~/.ssh/known_hosts"
> I tried to add it to sshd_config but ssh wouldn't even start.

No, this is not something to fix. This is the ssh utility looking for
that file in one of the default locations and not finding it. That's
just the result of the call which tried to access the file. The same
would happen in known_hosts didn't exist yet.

I mean, you can change the setting if you want (in ssh_config, and not
sshd_config, it probably is not starting because it's not a valid
setting for sshd_config), but you don't have to.

> The above error message it just might be the noise, linux to linux all
> connections work, it is just linux to windows it is not working.

--
Nuno Silva
Re: ssh from linux to Windows [ In reply to ]
On Sat, 6 Jan 2024 20:09:37 -0700
thelma@sys-concept.com wrote:

> I installed openssh server on Windows 11 and tried to ssh to it using the id_rsa.pub key
> but I didn't have luck.  I copied the key to .ssh\authorized_keys file.
> On linux the last line ending with "\"  on Windows Notepad replaces it with the "+" sign.
>
> ssh with password is working  but windows doesn't recognize the public key or maybe it is wrong directory  C:\Users\Garry Server\.ssh\authorized_keys
>

If ssh with password is working, did you try letting ssh decide for the
correct location for your ssh key via ssh-copy-id:
ssh-copy-id -i ~/.ssh/my_key username@example.com

First time it will of course log in via password, but any further login
should use the ssh key.

If the key is still not accepted, have you tried a different ssh key
type (e.g. ed25519). Maybe the server rejects RSA keys?
Re:[SOLVED] Re: ssh from linux to Windows [ In reply to ]
On 1/8/24 07:34, Nuno Silva wrote:
> On 2024-01-08, thelma@sys-concept.com wrote:
>
>> On 1/8/24 01:41, Nuno Silva wrote:
>>> On 2024-01-08, thelma@sys-concept.com wrote:
>>>
>>>> On 1/6/24 20:09, thelma@sys-concept.com wrote:
>>>>> I installed openssh server on Windows 11 and tried to ssh to it
>>>>> using the id_rsa.pub key
>>>>> but I didn't have luck.  I copied the key to .ssh\authorized_keys file.
>>>>> On linux the last line ending with "\"  on Windows Notepad replaces
>>>>> it with the "+" sign.
>>>>>
>>>>> ssh with password is working  but windows doesn't recognize the
>>>>> public key or maybe it is wrong directory  C:\Users\Garry
>>>>> Server\.ssh\authorized_keys
>>>>
>>>> Trying to run: "ssh -vv" I get:
>>>>
>>>> debug1: Authenticating to 10.0.0.130:22 as 'Glen Server'
>>>> debug1: load_hostkeys: fopen /home/joseph/.ssh/known_hosts2: No such
>>>> file or directory
>>>>
>>>> Where is it taking the : "known_hosts2" in home directory .ssh/ I only
>>>> have file "known_hosts"
>>>> In /etc/ssh/sshd_config (computer ssh is initiated from) I can not
>>>> find any reference to "known_hosts2"
>>>>
>>>> Nor, windows \ProgramData\ssh\sshd_config contain any reference to
>>>> "known_hosts2"
>>>
>>> I think the file to check would be ssh_config on the client side, not
>>> sshd_config. But it's possible it's not mentioned there either, as it
>>> seems to be part of the default at least in some systems, see for
>>> example
>>
>> The ssh_config on the client side id default, never changed anything in it.
>>
>>> https://serverfault.com/questions/1091575/why-does-ssh-think-i-still-have-a-known-hosts2-file
>>>
>>> This is just the usual approach of a user-specific file not existing
>>> unless it is created. I'd say you can just ignore this message and focus
>>> on the verbose messages about the authentication mechanisms.
>>
>> In the link above the suggest fix for "...fix $HOME/.ssh/known_hosts2:
>> No such file or directory"
>> to add "UserKnownHostsFile ~/.ssh/known_hosts"
>> I tried to add it to sshd_config but ssh wouldn't even start.
>
> No, this is not something to fix. This is the ssh utility looking for
> that file in one of the default locations and not finding it. That's
> just the result of the call which tried to access the file. The same
> would happen in known_hosts didn't exist yet.
>
> I mean, you can change the setting if you want (in ssh_config, and not
> sshd_config, it probably is not starting because it's not a valid
> setting for sshd_config), but you don't have to.
>
>> The above error message it just might be the noise, linux to linux all
>> connections work, it is just linux to windows it is not working.

It is working. The public key on Windows needs to be placed in C:\ProgramData\ssh\administrators_authorized_keys

Administrative user
The contents of your public key (\.ssh\id_rsa.pub) needs to be placed on the server into a text file called administrators_authorized_keys in C:\ProgramData\ssh\. You can copy your public key using the OpenSSH scp secure file-transfer utility, or using a PowerShell to write the key to the file. The ACL on this file needs to be configured to only allow access to administrators and System.
Re: ssh from linux to Windows [ In reply to ]
On 1/8/24 07:48, Andreas Fink wrote:
> On Sat, 6 Jan 2024 20:09:37 -0700
> thelma@sys-concept.com wrote:
>
>> I installed openssh server on Windows 11 and tried to ssh to it using the id_rsa.pub key
>> but I didn't have luck.  I copied the key to .ssh\authorized_keys file.
>> On linux the last line ending with "\"  on Windows Notepad replaces it with the "+" sign.
>>
>> ssh with password is working  but windows doesn't recognize the public key or maybe it is wrong directory  C:\Users\Garry Server\.ssh\authorized_keys
>>
>
> If ssh with password is working, did you try letting ssh decide for the
> correct location for your ssh key via ssh-copy-id:
> ssh-copy-id -i ~/.ssh/my_key username@example.com
>
> First time it will of course log in via password, but any further login
> should use the ssh key.
>
> If the key is still not accepted, have you tried a different ssh key
> type (e.g. ed25519). Maybe the server rejects RSA keys?

Nice command, thank for the input; but it didn't work with Windows 11

I run:
ssh-copy-id -i ~/.ssh/id_rsa.pub "Glen Server"@10.0.0.130
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/joseph/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
Glen Server@10.0.0.130's password:
'exec' is not recognized as an internal or external command,
operable program or batch file.

Number of key(s) added: 1

Now try logging into the machine, with: "ssh 'Glen Server@10.0.0.130'"
and check to make sure that only the key(s) you wanted were added.

Trying to login again still asked me for password.
On Windows 11 public key should be copied to C:\ProgramData\ssh\administrators_authorized_keys