Remote commands execution and file acces in Linux and Windows - linux

Suppose I have a server application installed in a few Linux and Windows machines. Now I would like to control it remotely. That is, I would like to start and stop the application, update the application configuration files, reads the logs remotely.
It looks to be easy in the Linux worlds. I can use ssh, scp, and probably nfs to execute commands in remote Linux machines and access files there. The problem is that I would like to execute commands and access files in remote Linux and Windows machines uniformly from a Windows machine. I need also some scripting capabilities too.
What is the best way to do that?

You can try to use cygwin http://www.cygwin.com/ on your windows machines and install a ssh server with it.

If you need graphical tools, use VNC
there is an OpenSS implementation targeting Windows at http://sshwindows.sourceforge.net/download/
since there is (besides Cygwin/MinGW) no possibility to run bash code (ksh/csh/tcsh code as well) you should make yourself familiar with the windows scripting host.

Related

Is there a way to directly edit a remote Linux server's code base through MS VS Code on my local windows machine?

Currently I manipulate the remote server through bash commands over putty, SSH w/ x11 forwarding and am messing with the web app locally and when I'm interested in deploying to the remote server I push the files over using a GIT repo.
My local machine is a MS Windows 10 with linux subsystem and the remote machine is a linux machine with Ubuntu 16.04.3 LTS.
This leads me to my question of is there a way to directly edit a remote Linux server's code base through MS VS Code on my local windows machine?
Thanks!
John
Hmm, this really looks like an x-y problem. More exactly, I do not think that you really want what you have asked.
In order to edit remote files with a local editor, the canonical way is to mount the remote file system (or a part of it) and then use any local tool. Samba allows to export a Linux folder as a Windows share, so you could easily go that way. The problem is that an IDE will try to compile and run the program locally on the windows system, which is probably not what you want. In addition, you will by default use Windows end of line convention (\r\n) instead of Unix one (\n), and cp1252 charset instead of utf-8.
IMHO, you should stick to x11 forwarding and use tools directly on the remote Linux box. The only acceptable use case I can imagine would be if the remote was a production system that you do not want to clutter with development tools, but in that case, I would strongly advise you to setup a local Linux dev. system and use it through x11 forwarding.

Remote installation on linux without using ssh

I want to run a script on a remote machine without using ssh.. Is it possible?
If yes then what all available options are there in linux?
Here are few details regarding the same.
1) On my machine i have a script, say a.sh, which performs installation of few packages. (such as lsof, ntp, vim etc).
2) I need to copy this script to the remote machine, and i want to execute it over there. (So that those packages get installated on to those machines.
3) what i am trying to achieve is if i have to do these packages installation on n no of machines, then with this mechanism i can automate this part.
Is there any preexisting infrastructure in linux which can help me doing this without ssh? (ssh to these virtual machines/remote counterparts is not possible)
Cheers,
Placid/
Ubuntu one has this form of remote package management availible , although on a personal level I simply prefer to scp / ssh exec scripts like this when deploying a change set to multiple machines .

Is it possible to set up a GitLab Linux server and work off Windows PCs?

I'm looking at setting up a gitlab server (using a linux machine) with several devs on Windows PCs using it. I basically wanted to know if that's possible? I can't seem to find a definitive answer!
Thanks!
Yes, it's definitely possible. I'm using just the same - GitLab hosted on a Linux server while devs are on both Windows and Linux (VMs running on Windows).
Techically, there's no difference to it. You use SSH and HTTPS for client-server communication which are standard platform independent protocols. It's the same as using github.com, gitlab.com or any other such provider from any operating system.
The place I work has Gitlabs deployed can be on a linux server, while developers can be on either Windows or Linux desktops.
Git makes use of SSH and to connect to remote clients and Windows doesn't support SSH out of the box, however the installer for git comes bundled with all the features you will need to run a shell and connect to a remote server via SSH on windows. It also includes a basic UI, Git-Gui. You can download the installer from http://git-scm.com.

How to copy files on remote Windows to local Linux on a Linux machine?

Currently, I'm working on a local Linux machine. I'm trying to use scp or similar Linux command-line tools to copy files from a remote Windows machine to my local Linux. I did some searching and found that most of the solutions are for local Windows cases (like putty and winscp), which don't really help.
Please advise.Thank you.
[UPDATE] Solved by installing cygwin's sshd service on Windows.
If you really want to use SCP, you will need an SCP server (actually an SSH server) on the Windows machine.
For example freeSSHd.
You will need to choose one of the options based on your own needs, there are a number of similar tools and freeSSHd was the first in the list on Google. I've used the Bitvise SSH Server in the past but it is only free for non-commercial use.
They are usually very easy to set up. You install them the usual way and run them for the first time. Depending on the tool, they may pick up your existing Windows users or you may need to manually create some users with passwords within the tool. Then, armed with your PC's IP address, you should be able to connect to the PC using SSH from the Linux command line.
If the windows system has a shared folder you should be able access that with smbclient which is part of the terrific samba project.
Usually somthing like:
smbclient //winmachine/share
Possibly using the -U username options to specifiy the username on the windows box.
Once connected, you can use cd to change folders, and get to retrieve files.
If there is no file share.... I dunno. Create one?
Syntax for copying from remote Windows 10 machine with built-in SSH server. Note forward slashes and drive style. Domain is not necessary.
scp user#domain#example.com:c:/path/to/file.txt .

Develop on Windows and running on linux machines

I need to develop applications for Linux but I don't want to either program on Linux (I already have all my "precious" tools setted up) or test it on Windows using some kind of POSIX for Windows and hoping that if runs well on that runs well on real Linux.
What's the better choice? Preferentially I want to use Eclipse IDE for compile/run/debug and run my programs on a Linux distribution that is running on a local VM or remote.
Right now I'm using a similar approach, but for Java Web Service testing on a remote server. Perhaps that's the way to go?
Edit:
In order to beter explain what I want, here is the steps that I want to follow:
Program in C, for POSIX compliant systems, using Eclipse on Windows
Make small tests on Windows, perhaps using Cygwin (this is not mandatory it's just to be quicker)
From my Windows Eclipse, I want to run/debug my application on a real Linux environment (could be a VM or a remote machine) and, preferentially, redirect the application stdout to my computer. The Linux machine only exists in order to garantee that everything runs ok, no need of even open it.
One thing that I didn't mentioned: all of the applications are command line, no need for GUI, just input from a shell and read the output.
First, install Linux in a virtual PC like VirtualBox or VirtualPC or something from vmware.
Then configure Eclipse for remote development. That allows you to run tools (like the debugger, the compiler suite, etc) on Linux from your Windows desktop inside of Eclipse. You edit the files just like you're used to, you debug as if the app was running local on Windows, etc. Eclipse will do the plumbing.
Remote server is the way to go. But most people have a powerful enough machine to run a 32-bit Linux distro in Virtualbox which is better than a real remote server because you have full control of setup and config.
But install cygwin including GCC and use that to run initial compile (and maybe unit tests) locally. Also, do use Valgrind on your Linux VM to help you produce cleaner code.

Resources