PsExec does not work with public key authentification

#1
Hello,

i setup ssh (cygwin) and execute command with psexec on the remote server, which works as expected. Then i added my pub key to my ~/.ssh/authorized_keys to login without pw.
After that i cannot execute psexec commands, it says ”handle is invalid“. Checked twice, remove my pub key from authorized_keys and it worked again.

Which parameter in sshd_conf is responsible for that?


Any help would bei great!

Thanks, Marco
 


Neemobeer

Windows Forum Team
Staff member
#2
Are you using the -s switch?
 


#3
yes, for example:
PsExec.exe -d -i 1 -s "C:\Windows\notepad.exe"
 


Neemobeer

Windows Forum Team
Staff member
#4
That's why it doesn't work. -s (run as SYSTEM) for the system user all network access is blocked it's a security feature.

You want to use -u and -h if you need elevated rights through a network connection
 


#5
but it works if i remove my key in ~/.ssh/authorized_keys on the target server

if i log in with password the psexec works!
 


BIGBEARJEDI

Fantastic Member
Premium Supporter
#6
Neem would know this programming environment better than me, but from the networking standpoint, if CYGWIN is using a Thin Client remote connection, and you disable the elevated network access, then sure the password works to let you into the remote computer running the CYGWIN executable, but the data is then all transmitted without the public key encryption (RSA?) and it's sent in Clear Text which any hacker can get at with a sniffer or via war-driving if you are using a mobile device such as a laptop or tablet to remotely access the CYGWIN via Wi-Fi. The exception to this is if your remote access to the host running the CYGWIN executable is being accessed through a VPN. If not, then it's wide open for anyone to see and if your work is proprietary and some one installs a keylogger or brute-force password breaker virus on your laptop or desktop machine, they can get into it in less than 1 day. This of course is more of a problem with a desktop PC as those are often connected via a high-speed Broadband connection and are left on 24x7. This allows those hacking tools to compromise first your windows password, and then your transmitted data in clear-text. Not too hard to do.

Just because something works, doesn't mean it's properly encrypted and secure.

Best,:up:
<<<BIGBEARJEDI>>>
 


Neemobeer

Windows Forum Team
Staff member
#7
I don't really see what would be different between using a password and key pair, all that is for is to authenticate to the ssh daemon. It shouldn't have any effect on psexec. The ssh tunnel is the same whether its password or key authenticated, and psexec only authenticate against the system its run on.
 


#8
i agree with you, the tunnel is the same and in theory there is no difference.
I'm using the "i 1"-switch also to address the current session.

The target is a vm, i can move the authorized_keys-file to the vm's desktop, then login per ssh to that machine (now with pw), psexec works fine, log out, put the authorized_keys-file back, log in (now directly without pw with key authentication), do psexec<my command> ---> handle is invalid.

i simply thought there are some parameters that i have to change in sshd_conf when using key auth against the daemon...

here is what it looks like (maybe do a fullscreen to read)
key
 


Last edited:

sug732

New Member
#10
Any other fix other than paexec? I face the same issue here...!!! the handle is invalid error for the public key authentication.
 


Neemobeer

Windows Forum Team
Staff member
#11
You can use powershell coupled with the Posh-SSH module and should be able to connect and run commands without psexec
 


sug732

New Member
#12
i am trying to use PAEXEC but it doesn't execute anything, it doesn't even is showing errors.
 


This website is not affiliated, owned, or endorsed by Microsoft Corporation. It is a member of the Microsoft Partner Program.