TFS SSH task in Windows Machine failed - ssh

I tried to connect a Windows machine that exist in another domain than our TFS 2018.3 exist.
I added "SSH" task, and I created new SSH endpoint with the remote machine IP, username and password, without a private key. I configured in the remote machine access of SSH for this username & password.
In the SSH task, I configure a simple shell command: ls.
The TFS agent succeeded to connect the machine but failed with this error:
Unable to execute command or shell on remote system: Failed to Execute process.
Full log:
2019-08-15T13:22:54.1491966Z Trying to setup SSH connection to ********#myserverinanotherdomain:22
2019-08-15T13:22:54.4085564Z Successfully connected.
2019-08-15T13:22:54.8120684Z tr -d '\015' <"./sshscript_1565875374136" > "./sshscript_1565875374136._unix"
2019-08-15T13:22:54.8121422Z Unable to execute command or shell on remote system: Failed to Execute process.
2019-08-15T13:22:54.8121745Z
2019-08-15T13:22:54.8180230Z ##[error]Command tr -d '\015' <"./sshscript_1565875374136" > "./sshscript_1565875374136._unix" exited with code 4294967295.
I think because it's a Windows machine and I try to execute a shell script. If I will install Git bash, for example, it can help?
Does the SSh task support only Linux machines? if yes, how can I connect a machine that exists in another domain?

SSH being a communication protocol is agnostic of OS. It is not Linux specific. But there seems to be a limitation for using SSH task on windows machine/build agent. Take a look at this similar question here: Not able to run bash script from windows using vsts.
I haven't found a documentation that clearly declare the SSh task not support on Windows machine. But I have found a task which also uses SSH--Copy Files Over SSH task. And according to the Q&A in official link:
Is this task supported for target machines running operating systems
other than Linux?
This task is intended for target machines running Linux.
For copying files to a macOS machine, this task may be used, but authenticating with a password is not supported.
For copying files to a Windows machine, consider using Windows Machine File Copy.
Instead of SSH. You should be able to use a local account on the build server and when entering the credentials. The account must have the same password as the account in the other domain. In other works make sure build account which run on the build agent are able to connect another domain.
Also make sure there is a trust relationship between the domains.

Related

Jenkins on unix executing script on windows server

I have a CI environment set up that build my project. It creates a set of sql server files, that i want to to send to my windows server. For that im looking into using scp, by installing copssh.
scp -r /file_in_unix/ user#windows_hostname:/cygdrive/c/
I want to execute a batch file on the windows server, but dont know how to do this?
any ideas?
Quite fast workaround is just to connect your Windows machine to Jenkins as another node. Your current unix job can trigger this job after successful execution.

Remote WMI as Administrator on Windows 8

I am trying to connect to a remote machine and run a script that gets me the OS-es from that machine. To do this I connect through WMI, run cmd /c bcdedit -v > bcd.txt. For some reason I keep getting access denied, the same thing as running bcdedit from a non-administrator account.
The WMI Security is set, that is running notepad or calc works perfectly. The user which is logged on, and which is used to connect to the machine is the Administrator. I'm stuck at this for days without any solution. Any workaround is welcome.
Note: OS in question is Windows 8
Note2: Workarounds tried(and failed): running another process that schedules a task with bcdedit(access denied), trying to set the process to run as administrator from the properties box(couldn't even start from WMI remotely)
Local admin account and network admin account are two different authorities.
You can access system BCD using local admin account or any account having needed access tokens.
I am not sure the information is available over SNMP.
Another way is to allow remote access to registry
and decode information from local \HKLM\BCD00000000 branch (mirrors system BCD).

Ways for Execute gacutil in remote machine

Is there a way to execute gacutil in to a particular (remote) machine given the IP address (or the workstation name) of the machine?
The machines in question are on an Active Directory Domain.
The user running the script probably won't have any special rights on either their local or the remote machine.
Some cases, will be administrator in machine.
Operating system is Windows XP , and remote machine Win2008 and Win2003.
Any programming language is fine but ideally scripting:
DOS Batch file (bat, cmd)
VBScript (WSH)
psexec
C# (worst option for me)
Have you tried Remote Gacutil? http://remotegacutil.codeplex.com/
You can always use psexec:
copy %Proj_folder%\SomeDll.dll \\destinationHost\c$\Temp
psexec \\destinationHost gacutil -I c:\temp\SomeDll.dll

remotely run a script sitting in a windows server from a unix box or from another desktop (Say windowS)

I have to run a batch job which sits in the windows server from my unix box.
Or from my local machine.
The win server has a userName/Pwd .
How do i programmatically connect to the windows machine and run the batch?
(The batch will change some file permissions in that machine)
Please let me know if there is a better way of handling this situation
A lot of this depends on how you authenticate on the windows machine, the network relation you have to it from your local and unix machine and what level of permission you will need to run the task ons the remote batch file.
I can say that in Windows, you could start by possibly creating a script that stores the username and password needed to connect to the remote machine in a variable, and in that script have it connect to the machine over a network and run the batch as that user.
How woudl you connect to the remote windows server? is it on a LAN or VPN type environment, do you connect with ssh or do you normally map it over the network?>

Copy files to a remote server via RDP using a script

We have a couple production servers that are configured to only allow access via RDP. There are no acessible shares. The dev team have no say in changing this setup but we want to automate code deployments to these machines. Presently we have to set Remote Desktop to share a local drive with the server, then RDP to the server and manually copy the deployment.
Any one know of a way to tunnel over RDP and drop files to a given directory on the remote host from the command line? The instructions will need to be included in an MSBuild configuration.
If you can get WS-MAN set up, PowerShell remoting and/or pmodem might be your ticket? https://web.archive.org/web/20180429054125/http://www.nivot.org/blog/2009/11/default