I am creating a run time powershell script on Linux machine and copying that powershell script to Windows machine. To connect to windows through "ssh", I am using Cygwin tool. To make the connection password less I copied my public in authorized_keys in windows Administrator account and now I am able to login without password like below and able to run some powershell script like echoing "Hello world" and running some Windows command from Linux machine
.
ssh Administrator@windowsServer
But, when I call any script that needs elavated access(tha's what I observed, I may be wrong also" it gives me error.
If I delete my public key from windows machine and perform the same operation from Linux machine(that is if i don't use password less connection), It asks me my password for Windows machine and it works.
So, in short, it does not work when I try to use passowrd less connection and works if I dont use passowrd less connection.
Please note it is not a permission issue or any issue to establish a connection to make a connection because I am able to run simple script making password-less connection and able to run many commands too.
Can you get a very simple proof of concept script to work? A quick "Hello-world" through the same mechanism would hopefully show if it is the process of elevating privilege or the commands actually running that is the problem. So a
Now I generate an ssh-key on Linux for user shekhar and copy it on Windows machine to make a password less connection.
shekhar@LinuxBox:~$ ssh-copy-id shekhar@WindowsBox.doamin.com
shekhar@WindowsBox's password:
Now try logging into the machine, with "ssh 'shekhar@WindowsBox.domain.com'", and check in:
.ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.
Now I run the same script again. Now it doesn't asks a password makes a connection with Windows box and display Hello world(first line of code) but fails on the second line
shekhar@LinuxBox:~$ ssh shekhar@WindoxBox.domain.com 'powershell "C:/scripts/abc.ps1"'
Hello World!
WARNING: Error initializing default drive: 'Unable to contact the server. This
may be because this server does not exist, it is currently down, or it does not
have the Active Directory Web Services running.'.
Get-ADComputer : Unable to contact the server. This may be because this server
does not exist, it is currently down, or it does not have the Active Directory
Web Services running.
At C:\scripts\abc.ps1:3 char:15
+ get-adcomputer <<<< -Filter * |select Name|select -first 10
+ CategoryInfo : ResourceUnavailable: (:) [Get-ADComputer], ADSer
verDownException
+ FullyQualifiedErrorId : Unable to contact the server. This may be becaus
e this server does not exist, it is currently down, or it does not have th
e Active Directory Web Services running.,Microsoft.ActiveDirectory.Managem
ent.Commands.GetADComputer
I am using Cygwin to establish ssh connection from LinuxBox to Windiws Box.