PowerCLI

 View Only
  • 1.  Posh-SSH: Issue on creating New-SSHSession using Public-Private Key authentication

    Posted Feb 20, 2023 11:38 AM

    I am creating new session in ESXi hosts as well as VCenter hosts using Posh-SSH module with root credential. and after copying public key in /etc/ssh/key-roots/authoized_keys, respective users are able to login into hosts using putty session via public-private key authentication process.

     



  • 2.  RE: Posh-SSH: Issue on creating New-SSHSession using Public-Private Key authentication

    Posted Feb 20, 2023 11:59 AM

    Judging from the private key file extension I assume it is a PuTTY Private Key (ppk).
    The Posh-SSH module expects OpenSSH format keys (pem).

    See (PowerShell) Convert PuTTY Private Key (ppk) to OpenSSH (pem) to convert.



  • 3.  RE: Posh-SSH: Issue on creating New-SSHSession using Public-Private Key authentication

    Posted Feb 20, 2023 02:55 PM


  • 4.  RE: Posh-SSH: Issue on creating New-SSHSession using Public-Private Key authentication

    Posted Feb 20, 2023 03:13 PM

    Google and Bing are your friends.

    But one good write-up is SSH - Public Key Authentication using the Posh-SSH Module with PowerShell



  • 5.  RE: Posh-SSH: Issue on creating New-SSHSession using Public-Private Key authentication

    Posted Feb 20, 2023 04:28 PM

    I guess I couldn't described my query properly here. Attempted all the way which i could see over the web before raising query here.

    like you suggested, I have followed the steps to convert ppk file to pem file and used it, however it is not authenticated properly.

    $session = New-SSHSession $esxi -KeyFile .\encrypted_openssh.pem -AcceptKey:$true -Credential root
    New-SSHSession : Permission denied (publickey).
    At line:1 char:12
    + $session = New-SSHSession $esxi -KeyFile .\encrypted_openssh.pem -Acc ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : SecurityError: (Renci.SshNet.SshClient:SshClient) [New-SSHSession], SshAuthenticationException
    + FullyQualifiedErrorId : SSH.NewSshSession

    Using Plink with same key authentication works fine

    PS C:\> .\plink.exe -ssh root@esxi.int.corp -batch -i .\id_rsa.ppk "ls"
    COVData.json
    CSUTData.json
    CSUTSettingsData.json
    CSUTiLODetails.json
    CSystemInventory.json
    altbootbank
    backup_cfg.dat

    Also i just want to use key similar way authentication like using putty & plink.

    would it be possible? 



  • 6.  RE: Posh-SSH: Issue on creating New-SSHSession using Public-Private Key authentication

    Posted Feb 20, 2023 04:55 PM

    Did you follow the procedure outlined in the post I mentioned earlier?
    That works for me.



  • 7.  RE: Posh-SSH: Issue on creating New-SSHSession using Public-Private Key authentication

    Posted Feb 20, 2023 05:14 PM

    it might be very silly question to ask which I might be doing wrong.

    On passing key file, it opens pop-up for credential.

    In my case user is root and we are having keys mapped to the same root credential for different users private keys. 

    would password be passed is root credential one or need to be generated against each private key?



  • 8.  RE: Posh-SSH: Issue on creating New-SSHSession using Public-Private Key authentication

    Posted Feb 20, 2023 05:39 PM

    Again, did you read that post I mentioned earlier?

    You might notice that the Credential parameter expects a PSCredential object and not a String as you do by passing 'root'



  • 9.  RE: Posh-SSH: Issue on creating New-SSHSession using Public-Private Key authentication

    Posted Sep 21, 2023 11:42 AM

    If you dont have anything valuable to reply apart from "look I think my search engine skills are better than yours" why do you reply at all? Everybody looking for a solution probably came across "the first link on Google". That "tutorial" there is absolutely worthless and does not solve anything.



  • 10.  RE: Posh-SSH: Issue on creating New-SSHSession using Public-Private Key authentication

    Posted Sep 21, 2023 12:43 PM

    Thanks for your feedback, luckily you have something "valuable to reply".