Skip to main content

Share applications with ssh (SaaS)

We are going to share our server's application programs to client system without actually installing it to client's pc. In this example we are going to use firefox as application program but any installed application(on server side) can be used for SaaS.

Server- RHEL7.2
Client- Windows or any linux based OS

For any type of service we need server applications which defines protocols that tells how the communication to client is going to happen.

For SaaS we will use SSH protocol-
Secure Shell (SSH) is a cryptographic network protocol for operating network services securely over an unsecured network.
The server will be open-ssh --
OpenSSH is the connectivity tool for remote login with the SSH protocol. It encrypts all traffic to eliminate eavesdropping, connection hijacking.

Step 1-
Installing SSH server --
Open terminal and type-
[root@www Desktop]# yum  install openssh-server

This will install the open-ssh server to your rhel7.2 server. In case you don't have the rpm file for open-ssh server then you can download it from Internet.

But there is a problem in it as it can not transfer graphics to client yet. In linux X window is used for graphics purposes. So we need to enable it on server side to transfer graphics using ssh.
Step 2 -
We need to change the configuration file of ssh which is placed in
 /etc/ssh/sshd_config. We can directly open it in gedit or type in terminal-
[root@www Desktop]# vim  /etc/ssh/sshd_config
You will find --
#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
X11Forwarding no
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
#PrintMotd yes
something this after scrolling through 80%

 Change X11Forwarding no to yes as -X11Forwarding yes

Step 3 -
After any change in any configuration file, we need to restart the service-
To restart ssh server- 
Type this command in terminal--
#systemctl restart sshd

To check the status-
#systemctl status sshd

To enable the service-
#systemctl enable sshd

We need to type the above commands and the
Server is now ready.  

SSH is a secure protocol, so it will need the client to log in first.
So create a user account for client--
#useradd clientname

 

For client(Windows/linux)--

Your server do not have a public ip, by which any client can reach your server through Internet.
So, we for now assume that the client and server is on a private network.
Just take another laptop/pc or  install a new O.S. on virtual machine of same computer.
The required condition is both should be connected.

To check conectivity--
Find IP address-
linux--
#ifconfig

windows--
in command prompt type--
#ipconfig  

By typing above command on both client and sever you can find the ip address of both written after their respective network cards.
Try following commands--
From client pc--
#ping (IP of server)
for example--
#ping 192.168.43.80

If it can ping then you are all set.

 Client(Linux)--
Let IP of server is --192.168.0.125
Type on client pc--

#ssh -X -l clientname 192.168.0.125 firefox

It will ask for password for client account
 Type the password and the magic would just happen 

(Here -X is use to enable X11 agent on client pc to recive the graphics.)

On client pc even if firefox is not installed, the firefox which is actually running on server pc and using server's resources, internet speed will come to client's pc as a interactive display which client can use.

Client can even login and use firefox from differnet pc each time by using his account name in above command, will still found the same history in all the browser he will use as the centralized storage is server's resources.

You can just replace firefox with any application, but that must be installed on server. 

This the magic of all these Technologies which we will call as SaaS. 

 Client(Windows)--

 To use SSH on your windows machine, You will need two softwares on client pc: A SSH client(Putty) and X11 display server(XMING).

On the client PC, download the two softwares: Putty and Xming from internet.

Putty will work like a SSH Client and Xming will work as a X11 display server for your client as these two servers do not come in most windows machines by default.

Once the server is all set up, you just need to do these simple steps:

- Open Xming.
- Open Putty and enter you server's IP



- Turn on X11 in putty and then click on Open



Now you will have a ssh terminal on you windows client pc:

- Enter the username and password.
- Enter the name of application (e.g. FireFox).

Now sit back and relax, the firefox running on your linux pc is now displayed on your Windows machine.

Yes, you can also type in "GNU-Terminal" instead of firefox and now you have a fully flexed Linux terminal on your windows machine.

You can also have a Android smartphone as your client.
Just download any ssh client and x11 display server from play store and you are good to go.

Comments

  1. can this be done in GUI? i want to access SSH server using website by embedding python script to it. is it possible to do that? and there will be list of apps in website so that client can access to it just by clicking specific app icon. so which langguage should i use to access ssh server using website. i am thinking of python.

    ReplyDelete
  2. Yes, can be done using your approach.
    place the icons on UI and give the path to your python script that will process accordingly and finally will provide the executable script file to download, that will have the desired code:
    You can use the following code for help:

    #!/usr/bin/python
    import os
    import cgi,commands
    print"content-type:text/html"
    print""

    x=cgi.FieldStorage()
    name=x.getvalue('anyname') //get the username
    sw=x.getvalue('softwarename') //get the application name

    f="ssh -X -l "+name+" 192.168.43.80 "+sw

    i1=commands.getstatusoutput("sudo touch {}{}.sh".format(name,sw))
    i=commands.getstatusoutput("sudo chmod 777 {}{}.sh".format(name,sw))
    j=commands.getstatusoutput("sudo echo \""+f+"\"> "+name+sw+".sh")
    k=commands.getstatusoutput("sudo tar -cvf {}{}.tar {}{}.sh".format(name,sw,name,sw))
    l=commands.getstatusoutput("sudo chmod 777 {}{}.tar".format(name,sw))
    m=commands.getstatusoutput("sudo mv {}{}.tar /var/www/html/tar".format(name,sw))
    print "GET"


    Thanks

    ReplyDelete
    Replies
    1. thank you so much for that. one question is, is it ok to use openstack for creating server and clients. will it be possible to run that python script to run CGI ?

      Delete
    2. Yes, depends on your project. Otherwise you can simple you a apache webserver. Thanks

      Delete
  3. Hello, nice tutorial. Can we use django to create simple GUI and access those commands? Does django supports shell script execution? I want to create simple basic GUI from which i can execute shell commands and then it should get output.

    ReplyDelete
    Replies
    1. Your tutorials helps us so much and it's also unique. Please upload more tutorials on cloud computing.

      Delete
  4. Thanks so much for appreciation. Will upload more such tutorials.
    Well I don't have much experience with django but i believe it uses WSGI instead of CGI. But it is still based on pure python with some additional libraries. It should work on that too.

    ReplyDelete

Post a Comment

Popular posts from this blog

Platform as a Service (PaaS)

Platfo rm as a Servic e ======================================================== I n simple words in this project we are going t o develop a online coding webapp where you can just choose the programming language in which you want to code and Execute your code in the website itself. The magic of using webserver and docker technology in PaaS is  you can just connect all your device with th e server and an yone conne cted with it will have acce ss t o the Coding W ebsite we will de velop. 1. First we will Develop the Web Page and Save it as  paas.html in the html folder of you apache server. Write the Following code in that -- <form action ="http://192.168.43.80/cgi-bin/paas.py"> <br> <pre>     <h2>Select the Language</h2>    <select name="languages">   <option value="java">Java</option>   <option value="python">Python</option>   <option value="c">C

Overview

Namaste!   Welcome to my blog.. Here we are soon going to develop a own cloud infrastructure from the scratch. If you study here from the beginning  to end with self practice at your home I can assure you that within maximum of 2 months you can develop your own cloud. In our cloud project we will mainly include following features -- #################################################################################################### Software as a Service (SaaS) Storage as a Service (StaaS)[Object and Block] Infrastructure  as a Service (IaaS) Container as a Service (Caas) Platform as a Service (PaaS) #################################################################################################### The tools and technologies we are going to work on are-- Redhat Dockers KVM hypervisor Mariadb Python Python CGI HTML, CSS, Java Script The above names sure looks bit strange and you may think that it's very complicated and not for me to learn. But i can say