N
N
Nordman992021-12-23 10:39:36
linux
Nordman99, 2021-12-23 10:39:36

Why can't I send my SSH public key from Linux to Windows?

Good day everyone, this is the situation - I want from Linux, Ubuntu 20.04, connect to Windows 10 20H2 remotely via SSH
, I set everything up, and on Ubuntu and on Windows the sshd service works, the port listens, I generated keys on both Windows and Ubuntu, I
tried to connect first without authorization by keys - only by password, everything is OK, from ubunta I connected to Windows, I executed

$ssh [email protected]

entered the password and that's it, I'm in Windows, but I need authorization by keys,
In /etc/ssh/sshd_config I set the line PubkeyAuthentication yes
Also and in Windows in the file c:\windows\system32\openssh\sshd_config
sshd and restarted here and there I

execute

$ssh-copy-id [email protected]

I get the following output:

/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
[email protected]'s password: 
"exec" �� ���� ����७��� ��� ���譥�
��������, �ᯮ��塞�� �ணࠬ��� ��� ������ 䠩���.
�⪠���� � ����㯥.
���⥬� �� 㤠���� ���� 㪠����� ����.

then I execute

$ssh-copy-id [email protected] &> ~/ssh_log (By the way, where does SSH keep its logs? I didn’t find anything in /var/log/)
I look in ~/ssh_log, there is the following:

/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
"exec" не является внутренней или внешней
командой, исполняемой программой или пакетным файлом.
Отказано в доступе.
Системе не удается найти указанный путь.


What to do?
I read https://qna.habr.com/q/1010371 but the advice from there is clearly not related to my problem

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Saboteur, 2021-12-23
@Nordman99

You need to look through the configuration of your sshd server on Windows and see where it thinks the user's public keys should be.
It could be either $USERHOME/.ssh/authorized_keys or $USERHOME/.ssh/authorized_keys2 or anything else.
ssh-copy-id may not know where the public keys should be in Windows, it makes no sense to use it in this case.
Read the documentation for the Windows sshd server to understand where it looks for the user's public keys.

U
uvelichitel, 2021-12-23
@uvelichitel

1. It is necessary to %programdata%\ssh\sshd_configregister

Match User YOU
             AuthorizedKeysFile C:/Users/YOU/.ssh/authorized_keys

2. ssh-copy-id will not work with windows. Try
cat ~/.ssh/id_rsa.pub | ssh [email protected] 'mkdir -p ~/.ssh && type con >> C:/Users/YOU/.ssh/authorized_keys'

if it doesn't work try scp
scp ~/.ssh/id_rsa.pub WINDOWS_IP:C:/Users/YOU/.ssh/authorized_keys

if it doesn't work, transfer it with a flash drive.

A
AlexVWill, 2021-12-23
@AlexVWill

wrote
https://forum.ubuntu.ru/index.php?topic=316363.msg...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question