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

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?>

Related

TFS SSH task in Windows Machine failed

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.

How to save a file to a local machine that you are editing via SSH

Here is my situation:
At work I have to ssh into a server from various different machines. I frequently need to update the file on the remote machine but also save a copy locally (on whichever machine at work I am using).
I usually use emacs on the server I have ssh into but not always.
Is there a direct way to save the file I edited while ssh'd into the server on my local machine? I.e. pipe it to my local machine somehow?

How do i connect to Unix File System which is in Different Remote servers

I wanted to place a file in UNIX file system from local desktop using Excel VBA, which is in remote server,which is in another Remote Server.
Problem Statement:
First I have to connect to Remote Server 1 and then i need to connect Remote Server-2 which is in Remote Server-1.
The Unix server is in Remote Server -2.
Please let me know possibilities of connecting to Unix Server from my local desktop using Excel VBA.
Thanks,
DEEPAK
Quite a confusing setup but your "server in a server"... is it a virtual server? If so, your admin should have set it up to have its own resources and network access so you don't have to access one inside another. You just connect to the server you need.
If you are connecting to the UNIX server from a Windows machine your admin should have installed and configured SAMBA so you can then access files through Windows Explorer.
I've made an assumption at the beginning because I'm unsure of your precise configuration as I've never heard of a server in a server unless you're talking about a virtual server, but these are usually seen as individual servers that can be directly connected to...
This may answer your question
check it out here:
http://www.thinkplexx.com/learn/howto/linux/system/using-pipe-and-ssh-to-connect-commands-between-different-unix-hosts-output-local-cat-less-etc-into-remote-files-grep-or-watch-remote-logs

Disk2vhd Hyper-V server question

Hello all I have a backed up about 30 servers using disk2vhd and now I have built my first of many hyper-v severs I did not realize this is all command line I did download CoreConfigurator and that does have some functionality I have been looking for. My question is how do I get the VHD files to run a Vitual Machines? its all command line I tried via vbs to mount the VHD's and I have not been able to any help on this would be great!
Thanks!
If you are using servercore, You maybe can do everything from the command line but I always prefer to have one computer running a Non server core version of windows 2008 to be the management server. You will load up Hyper-V manager on the non server core box and manage your Hyper-V server.
To have no "management" servers or desktops on your network will be a big pain IMO for management.
Using Hyper-V Manager you can quickly load the VHD's as VM's.
So load up Hyper-V Manager on a desktop PC on your localnet, and use its connect option to connect to your servercore. (Make sure your firewall settings are ok on servercore using coreconfig)

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