SSL Socket Communication in CGI a good idea? - linux

I would like there be a way to communicate between and Apache Server and an Application running on a Linux laptop.
The only way I can think of doing this is using SSL Sockets in a CGI python or perl script. Is this a good idea by any chance?
The Apache Server and the application are on the same machine, so perhaps having encryption might not be a big deal, since an attacker would need to gain physical access to hack the process. On the other hand it is connected to the network, and possibly could be sniffed.
Is encryption in such a case? Could an attacker sniff the data in that case?
Also if this is indeed a good idea, does anyone have resources on how to implement ssl socket with perl or python?

If you are using loop back address (local host or 127.0.0.1), i don't think it can be sniffed on the network since it doesn't go beyond your interface card. So encryption is not a concern here.
For the second part, following is an SO example python client though uou can find tons any way.
Another thing is being on Linux, you can simply connect via shell too. Just use netcat i.e. nc. You can send any text to server as well as read back using this command line application.
Don't reinvent the wheel.

Related

How to set up a tcp server on a personal computer

I'm not that experienced with networking - hence why I'm asking this question - so please have patience with my inexperience.
What I want to do is set up a server on my computer that my friend's computer could connect to through the internet and we could play a game (very surprising indeed). A vague idea that I had was I could run a VM to handle it. My questions are:
Is there a way I could establish a connection between our computers without having to pay for a separate server?
Is there a Python 3 library that's good for beginners (in networking - not Python) that can do this task?
Note 1: It is a turn based game so the processing does not have to be really fast.
Note 2: I have a basic understanding of sockets, servers, etc, I'm just not familiar enough with them to find what I'm looking for elsewhere.
Are you familiar with netcat? What do you mean by "(in networking - not Python)". The reason I ask if your familiar with netcat is because if you are sockets should not be too hard to program (I say that respectfully they can be weird at first glance). Your most likely going to have to open a port on your router to do this. Depending in the game will be the complexity of programming this. But basically this is what you want right.
TCP Server (Listening) (Your Friends House)
TCP Client (You)
TCL Client -> TCP Server
If your gonna be using a windows gui just use VNC Viewer: https://www.realvnc.com/download/viewer/ or TeamViewer: https://www.teamviewer.com/en/ or enable RDP.

Windows program to communicate with Virtualbox

I am wondering if it is possible to write a program on Windows that communicates with a program within a Linux Virtualbox on the same machine. If this is possible, what is the best approach to doing this? Is there a way to do this without using the internet to communicate?
I found instructions showing how you could potentially use SSH, but I have never tried doing this before, so I do not know if using SSH to communicate would be the best option.
I was going to put this as a comment to a very vague question, but then it got too long.
It depends what you mean by "communicate"....
If the Windows machine should start a program on the Linux VM, you probably want plink.exe - see here.
If you want to transfer whole files, you probably want scp or FTP or FileZilla - see here.
If you want to send small messages occasionally, maybe netcat, also known as nc - see Netcat Cheatsheet here.
If you want full-on, high speed, continuous messages, maybe sockets or some messaging protocol like mqtt.
If you want to share data structures, like lists, queues or sets, you could allow both Windows and the Linux machine to access a shared Redis database - see here.
Or maybe it is enough to share a filesystem between the two machines - in which case you can make a Shared Folder in VirtualBox on your host and the VM can just mount that and read/write it. See diagram:

Script for merging two SSH connections together?

I'm trying to write a bash script to merge 2 already-existing SSH connections.
For example, if I have an embedded device automatically creating an SSH connection to my server (from behind a firewall), how can I connect to that server in the middle, and jump into the already-existing connection from that embedded device?
I have looked into the possibility of using the server as a 'jump host', but it seems like I will need to reliably determine (and send SSH requests) to that embedded device?
I have also looked at having the embedded device create a 'screen' on the remote server and connect to that, but that just seems like it would be operating on the remote server.
I'm sorry if this is the wrong place to ask this, but I don't know where else to ask.
It sounds like your requirements are going to need either a uPNP solution or tunnelling solution to get through your firewall. The following link discusses reverse SSH tunneling as one part of this solution.
https://unix.stackexchange.com/questions/46235/how-does-reverse-ssh-tunneling-work

Listening a particular port on linux to access data comes from mobile device

i am newbie to Linux platform, i am working on java technology.
what i have to do is : Having a program that running on mobile devices,that sends some data to my Linux machine, now i have to create a program in java that
listen to a particular port.
access data comes on that port(which is sending by mobile device)
save that data to the database.
response back to the mobile device.
i.e. i would make my Linux system as server that can listen from many clients(mobile devices), but not getting how to configure this environment... :(
i used cent OS 5.4 and
installed jdk1.6.0_24
any help would be appreciated.....
thanx in advance!
khushi
One of Java's greatest strengths is that you can pretty much ignore the host operating system as long as you stick to core Java features. In the case you're describing, you should be able to accomplish everything by simply using the standard Java networking APIs and either the JDBC to access an existing, external database or you could choose any number of embedded Java databases such as Derby. For your stated use case, that you'll be running the application on Linux is pretty much irrelevant (which should be good news... you don't need to learn a whole operating system in addition to writing your app ;-).
Here's a nice client/server tutorial, in that it is broken into steps, and adds each new concept in another step.
Here's another client/server tutorial with much more detail.
I would write it to accept one connection at a time. Once that works, I would study the new(ish) java.lang.concurrent classes, in particular the ExecutorService, as a way of managing the worker bee handling each connection. Then change your program to handle multiple connections using those classes. Breaking it up in two steps like that will be a lot easier.

Using IPsec to secure traffic

I have a client server environment and would like to secure the network traffic using IPsec. What is involved to get this implemented? The application is working fine, I just need to secure the traffic between computers.
What do I need - certificates on each computer for example? Do I need to make changes to the socket read/write code?
Since IPSec is implemented at the IP level, your application does not need to be changed for IPSec (and it will not notice anything about it).
What exactly is needed for IPSec depends - but you'd be better off asking this question on serverfault.

Resources