Windows Environment variable passing through OpenSSH - ssh

I am using OpenSSH for Windows in order to be able to connect a Linux machine to a Windows machine.
To do that I have installed a SSH server for Windows v5.6p1-2.
I also have declared the allowed users.
From my Linux machine, I connect to the Windows machine with "ssh user#machine" command.
My problem is that once connected, I get only some Windows environment variables but not all system and user defined variables.
Is it possible to get all the Windows environment variables ?
Thanks,

"This is to limit security holes."
Check this out it has a few solutions.
http://cygwin.com/ml/cygwin/2006-11/msg00394.html

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.

Manage windows 2008 server from linux

Is the way to manage windows from linux terminal using only base windows soft? E.g. how can send files from linux or run some script? Install ssh server on windows unfortunately not suitable.

Hyper-V Server Core Guest OS Install

I am new to Hyper-V and Server Core but I am stumped as to how to install a guest OS from an ISO using only PowerShell.
I have downloaded the Hyper-V Server ISO and installed it on my server. It only installs Server Core and does not give me the option for a full GUI option. I configured its network settings, etc and all looks ok. So Server Core installed properly and Hyper-V feature is enabled. I can use PowerShell to create a VM with VHDX and link my Guest OS ISO to it. When I start the VM there is no console UI to install the OS.
How are you supposed to install a guest OS with no console interface to setup the OS?
Note, there is no option under this configuration to enable the OS GUI as some posts have suggested.
First, please don't confuse "Server Core" with "Hyper-V Server". "Server Core" is an installation mode of Windows. Among other things, it can be converted to GUI mode, which is why people keep telling you to just turn the GUI on. Hyper-V Server looks like Server Core but it is not Server Core.
For your actual problem, you're not going to find a simple out-of-the-box solution. You could work up a complete unattended installation process. You could set up a Windows Deployment Services server and have it install via PXE boot. I think some of the third-party Hyper-V management solutions allow you to connect to the console of a VM from within the local Hyper-V Server.
Hyper-V Server was designed with headless operation in mind. It was expected that you would use it to configure and perform maintenance on the management operating system and, if desired, the virtual machines as containers. The guest operating systems themselves were not really meant to be managed from within Hyper-V Server. What it's expected that you'll do is use a full GUI, whether another copy of Windows Server or a Windows desktop operating system running Remote Server Administration Tools to remotely connect to Hyper-V Server and manage its VMs.

PsExec Windows 8 access denied

I've 8 computers running Windows 8 (the basic edition) and I'm trying to run some application on each of them with a batch script.
I tried:
PsExec.exe -i -d -u USER -p PASSWD \\PCNAME explorer.exe
But it gives me:
PsExec v1.98 - Execute processes remotely
Copyright (C) 2001-2010 Mark Russinovich
Sysinternals - www.sysinternals.com
Couldn't access GATE1:
Access is denied.
It works fine on other PCs with Windows 7 Professional.
Does it works just on Pro edition? If so, is there a way I can run something remotely on Win 8?
I resolved the same PsExec "Access is Denied" error on a Windows 8 Pro 64-bit target machine with the following registry modification on the target machine:
Registry Location: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System
Add DWORD LocalAccountTokenFilterPolicy
Set LocalAccountTokenFilterPolicy to 1
(Reboot)
In domain based environment, Microsoft PowerShell Remoting may be an alternative to PsExec.
In workgroup setup, especially among many different versions of Windows it may get bit challenging.
PowerShell remoting requires PowerShell 2.0 on both client and server.
Also, ssh with it's all capabilities (including launching remote commands) works under Windows, even free servers (freesshd) and clients (PuTTY family) are available . Downside is requirement for highly privileged account (usually, in some Administrators group) - at least for initial setup.
The GATE1 part in your log is interesting - PsExec requires so called "admin share" enabled (not sure does it work in Windows 8). I'd bet it's not the system, but a network issue.

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