0
votes

I am trying to connect to git using PowerShell remotely (Windows).

I have created a PowerShell script on the target machine which runs correctly (if I use remote desktop to access the machine).

I am connecting to PowerShell using SSH using a public SSH key.

I am using Enter-PSSession -ComputerName servername to connect to the remote machine to save the need to use a remote desktop connection. This is also due to the fact that some users will need to run this script without direct access to the machine.

I have already cloned the repository on the remote machine which I performed directly on the remote machine.

When I run the same PowerShell script remotely I get the following message when trying to do a Pull:

Host key verification failed.:String

I am using roaming profiles so the key I generated on the server will be the same as stored in my user directory on both machines.

I am very new to using SSH keys and I assume this is a security feature.

Is anyone able to help resolve this one to get it working remotely. I do not need it to work on the remote machine directly if this would help.

1

1 Answers

1
votes

I fail to comprehend the real essense of your question, but maybe you'll be able to derive some clue from my comment.

When an SSH client connects to an SSH server, the latter sends to the client its key. Normally the server has a single SSH key which never changes. The client must trust the server's key—that fact lies in the root of the SSH's trust model.

Because of this, the SSH client software logically associates the fingerprint of the server's key with either the IP or the host name you use to connect to the server. Typically, when the client SSH software detects it have not yet connected to the particular server you're connecting to, it will show you the fingerprint of the server's key and ask you whether you trust it.

In theory, it means you first wrote down that fingerprint while sitting at the console of the server, and when the SSH client asks you about trusting the server's key, you compare the fingreprint it shows to you with the one you wrote down.

OK, so you "accept" the key, and then the client typically saves the pair IP+fingerptint and/or hostname+fingerpting and won't ask that question again—unless it detects the fingerprint is different from what it saved (in which case it loudly complains because this might mean an attempt to craft a Man-in-the-Middle attack on you).

What I'm leading you to, is several points:

  • The SSH client and server and not interchangeable in the sense it may be OK to connect from machine A to machine B via SSH, but not vice-versa: a client key's on A is just a client's key.

  • Even if you connected from A to B, it does not mean it will be OK to connect from C to B: A might have the B's key trusted, but C won't.

Dunno whether it helps, but that would be too much for a comment.