Windows 10 SSH keys

后端 未结 11 1763
难免孤独
难免孤独 2020-12-12 14:57

I am having a really hard time getting my SSH keys up and running after installing Windows 10. Normal method is create it and throw it in the user\'s account under .ssh. T

11条回答
  •  半阙折子戏
    2020-12-12 15:15

    If you have Windows 10 with the OpenSSH client you may be able to generate the key, but you will have trouble copying it to the target Linux box as the ssh-copy-id command is not part of the client toolset.

    Having has this problem I wrote a small PowerShell function to address this, that you add to your profile.

    function ssh-copy-id([string]$userAtMachine, [string]$port = 22) {   
        # Get the generated public key
        $key = "$ENV:USERPROFILE" + "/.ssh/id_rsa.pub"
        # Verify that it exists
        if (!(Test-Path "$key")) {
            # Alert user
            Write-Error "ERROR: '$key' does not exist!"            
        }
        else {  
            # Copy the public key across
            & cat "$key" | ssh $userAtMachine -p $port "umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys || exit 1"      
        }
    }
    

    You can get the gist here

    I have a brief write up about it here

提交回复
热议问题