Reputation: 3938
I want a feature in my program to switch user and execute shell commands on the same host using java. For which I'm using JSch, which basically does an ssh to the same host with given user credentials.
The problem is, for Linux based machines I can run 'hostname' command and get the hostname to connect, but with Windows platform there no such command that returns the hostname as the only output which I can use.
Is there any script or command that i can run to get the IP or hostname for Windows?
Upvotes: 0
Views: 586
Reputation: 40066
First, hostname
command exists in Windows for quite some time. What is the Windows version you are working on.
Go back to your real problem: I don't think Windows provide built-in ssh server . Even you install an SSH server yourself, I doubt it really allow you logon using another user with his privilege.
If you are just looking for a way to run command under another user, you can use runas
in windows.
e.g.
runas /user:yourmachine\anotheruser yourCommand
Upvotes: 1