SSH Tutorial - How to access UNIX server from WINDOWS client

Hello Buddies.

Here is a quick tutorial to get hands-on experience in accessing a remote machine.
It can either be a case of a remote machine being used as a server or as a storage location.

In case your remote machine is having Windows platform, things become really straightforward. Just need to use MSTSC – Remote login through your windows machine, enter the credentials, and boom, you are already on the remote machine!

Complications occur when the remote machine is UNIX based.

For the same, this tutorial will be based on the below scenarios –

  • Remote machine: UNIX based – here it’s Fedora
    • Remote machine will be hosting a simple HTML page
    • It will be using Apache HTTPD as the server
    • To enable access, it will use SSH
  • Client machine: Windows-based
    • It will use putty for SSH access
    • It will also update the HTML content of the remote server


Sounds interesting?
 Cool! Let’s begin the discussion.


All About Remote

Using Apache HTTP Server project here.

Install:         sudo dnf install httpd
Start:           sudo systemctl start httpd.service
Check:        using http://localhost.

The root directory of your web server is now situated at /var/www/html/ with root as the owner.

Comment out all the lines in /etc/httpd/conf.d/welcome.conf default page landing. 

Create an index.html file with your content in the /var/www/html/ directory:

<html>
    <head>
        <title>Hello world</title>
    </head>
    <body>
        Hello world!
    </body>
</html>

Now, when you visit http://localhost, you will see your new index page.

Yeah! It looks cool! Changes are picked up nicely and easily!


Can I access this web page from any other machine?


Here comes a tricky part. By default, each OS has restrictions over ports, and firewalls as well.
So, you need to, first of all, find the public IP of your system and allow access to a port that would be exposed.









In a UNIX machine, you can check the iptables, for the status of the ports.

  iptables -L

Also open the port 80, for the apache server.

  iptables -I INPUT -p tcp --dport 80 -j ACCEPT

For the IP address of the machine, use ifconfig.

Boom!

Hit the URL from any machine now – http://192.168.xx.xx:80

And you will see the content !!!





 







What if I want to change the content from my client machine?


Here comes another tricky part, that surely demands at least one hands-on experience.

  • Get openssh-server on your server machine 
    •  sudo dnf install openssh-server






  • Start the ssh service
    • sudo systemctl start sshd.service
  • By default, it will use port 22. Remember this!
  • Also, doing some authentication stuff here.
    • Use keygen command to generate an RSA private key at the server side.
    •  # ssh-keygen -t dsa
  • Save the key, for now, bypass the passphrase as empty.


Use the saved private key in your windows client now. How? 
Check this below!

  • Install putty in your windows client.
  • Open puttyGen.
  • Load the imported private key.
  • Open putty, enter the IP address of the server machine.
  • Remember the default port number? Yes, correct. It should be 22.


Hit it. Boom! You are in the server machine now.

Remember where your HTML content was being picked up from?
Yup, correct!

Update the content at /var/www/html/ 


















Refresh the web pages, and you will have new content with you.




















So, this was a quick one! Keep exploring.

And Happy coding!










Featured post

Oracle SQL Scheduled Jobs - An Interesting Approach

  Oracle SQL Scheduled Jobs A DB Scheduler is the best way to automate any backend database job. For instance, if you want to process the p...