Autoit script on remote machine - azure

Currently I am running a jarfile from my CENTOS machine that takes parameters to make a connection to azure Windows VM using WINRM.
I get the sessionID of RDP and using psexec I execute my autoit script on the RDP sessionID (this assumes that I need to have already a RDP connection established).
psexec.exe -i 2 "C:\Program Files\AutoIt3\AutoIt3.exe" "C:\Users\admin\runNotepad.au3"
The script runs perfectly when I have a RDP session maximized/opened. If I minimize the RDP window some commands do not work, as for example the Send command.
How can I guarantee, taking my setup, that a session with GUI is opened and how can I bypass(if there is a way) the constraint of having the RDP window maximized in order to run the test?
I can also change my architecture if required (apart from the CENTOS machine).
Thanks

Related

Far Manager NetBox SFTP can't connect to the linux server

I'm trying to connect to the RedHat Linux server through Far Manager 3.0.5800.0 x64 and NetBox plugin with SFTP. But it doesn't open the session as I expect it and doesn't exposure any errors. The connection screen blinks once and disappears, get me back to the NetBox: Stored sessions panel.
I CAN connect to that server through putty ssh, and it seems to be completely ok.
I CAN connect through Far Manager to THAT server as a different user also as a root user.
The problem was that I recently wrote in the .bashrc file some strings with "echo" command. And it seems to be after that the NetBox doesn't want to establish a session by that user.
So just inspect your .bashrc file and clean all echo commands.

How do I reopen an open program on a linux server, with ssh connection in Powershell

Basically I have a linux server, that I can connect to using ssh -i *pvKey* *user#host*.
When I'm connected I can open a java application, like I have. The linux server stays open 24/7 and I believe any application I open does the same. How do I reopen an open application if I close windows powershell.
Let's say I go to bed and close windows Powershell, I believe the java application will stay open during the night, which is what I want. How do I reopen that java program again after connecting to the server, so I can continue sending commands in the java application.
For more specific information: The java application I'm talking about is a minecraft server, which I want to leave on 24/7 (with some restarts obv). I want to be able to reopen the java program of the mc-server that has stayed open, so that I can send more commands and possibly restart the mc-server, without having to log into it in minecraft, stopping it, and reopening it in powershell.
This is the first time I try to work with a linux server and powershell, so please excuse my lack of knowledge.
Your remote shell automatically kills all processes that are running in the shell when you exit the shell.
I would probably use screen for this usecase.

Running GUI without need of remote desktop connection on-going

Build: Server with Ubuntu 18.04 in data center with Ubuntu Mate Desktop interface.
As I understand, any GUI app needs a display in which to function. I connect to the server via x2go to display the ubuntu mate interface.
Once connected, I have a scheduled cron job that launches a terminal, a GUI and some commands.
Everything works perfect as I have previously detected what display I'm using as a user and specify that to launch the terminal and the commands.
Problem: if I'm not connected via x2go client to the server and provide that display, I noticed today that the cron job didn't launch at the specific time (08:50), which was previous to my x2go client connection (09:23); it just launched when I did the x2go client connection from my desktop manually -- my understanding is that it didn't launch because there was not any available display.
I'm not technical enough to get more deep into this problem.
¿Is there anyway in which I can make the cron script function (i.e. that it launchs the terminal and the GUI) without the need of manually getting into my desktop and launching the remote desktop client (x2go)?
My ideas go for having another minimal setup in that data center or another that takes the advantages of being there and have a physical monitor to display constantly connected to the main server OR just manually entering the server via x2go every day.
EDIT: When I disconnect the x2go client session from the server, the launched GUI and etc perfectly maintains, without dissapearing because "I have terminated the session and eliminated the display".
Finally got it working with the great help of one of x2go founders (Oleksandr Shneyder) after understanding how x2go handles the sessions and the X server.
Sessions can suspended/hibernated, disconnected and terminated.
Suspended/hibernated: when "manually" or automatically the x2go server side suspends so that it saves resources.
Disconnected: when you exit the session window and the x2go client in your desktop/laptop.
Terminated: when you log out from the DE environment or issue the x2goterminate-session command in the terminal inside the session.
My x2go app was somehow entering into suspending mode in the server, causing that the display (50 in my case) in which the scheduled cronjob need to be run and launche the GUIs, "was not awaken" until I entered into the session via the
app. In that moment, the cronjob started executing.
To tell x2go server to not hibernate, I needed to change the X2GO_NXOPTIONS in /etc/x2go/x2goagent.options to X2GO_NXOPTIONS="sleep=0"
After this, everything functions perfectly in the server.
Hope it helps others.

"421 Active data channel timed out." with FTP client connection from Azure VM from SQL stored procedure

We're migrating from a Windows server box to Virtual Machines on Azure. Our SQL stored procedure uses Integration Services packages to generate feed files and upload them to client ftp servers.
We do this by building script files and using the native ftp.exe client on Windows. My script file looks like this:
open ftp.ourserver.net
myusername
mypassword123
lcd G:\
cd /
prompt
put "G:\DataFeeds\SmithCo_02272017.txt" "SmithCo_DailyFeed.txt"
bye
This works fine on our old server. When I use command prompt to run this code I'm getting:
421 Active data channel timed out.
I can upload the file manually with just a basic connection using WinSCP client on that machine.
I thought it was a port issue so I created an outbound rule in Windows Firewall for port 21, allowed all connection.
Then I created an endpoint in Azure for port 21 as well.
Is there another step to open this up or something I may be missing?
The Windows command-line ftp.exe supports the FTP active mode only. In the active mode, the server has to connect back to the client to establish data connection for a file transfer. More over the ftp.exe does not allow you to pick, what port is used for the data connection. It randomly picks any available port number above 1024. So you would have to create end points for all ports above 1024. That's possibly something you do not want to do. Though you can try.
WinSCP works, because it (as most modern FTP clients) uses the passive mode by default. For the passive mode, you do not need to open any ports on the client side.
Read my article about network configuration for FTP active and passive connection modes for details.
As WinSCP works for you, you can use WinSCP scripting interface to replace your ftp.exe script.
It would be like (ftp.txt):
open ftp://myusername:mypassword123#ftp.ourserver.net/
lcd G:\
cd /
put "G:\DataFeeds\SmithCo_02272017.txt" "SmithCo_DailyFeed.txt"
exit
(Though the lcd is redundant, both in your and WinSCP script).
And run the script like:
winscp.com /script=ftp.txt
See the guide to converting Windows FTP script to WinSCP script.
(I'm the author of WinSCP)

How Can I connect to Amazon Linux instance using Remote Desktop from Windows 7?

I created an EC2 Amazon Linux instance (yes, an amazon version of linux..)
it is launched but I can't connect using Remote Desktop...
am I trying to do something crazy here?
I got a message that Remote Computer is not available on the network
If you mean Windows RDP (Remote Desktop) that is your problem. Most likely you will need to use an SSH client to connect. I suggest Putty.
You should've received an SSH key when you setup your server. You will need to convert that key using PuttyGEN (same page as the Putty download) to convert it then use it with Putty to access the server.
Trying to walk you through the process of installing a GUI and VNC on the server is a bit much for here but give this video a shot. It seems pretty thorough and from skipping through it I saw no obvious errors in his process.
Try installing the vnc4server package. Then you can use a client such as TightVNC to connect from a Windows machine. You'll also need to open up port number 5900 in your firewall, which is the default for VNC.
You'll also have to have a desktop environment installed on your EC2 instance - by default you may only have the server packages which will not give you a GUI.
For your information, some folks posted remote desktop conf for EC2 instances.
http://activeintelligence.org/blog/archive/remote-graphical-linux-desktop-on-ec2/

Resources