Remote Execution of the Program using SSH & Docker

Remote Execution of the Program using SSH & Docker

What is Remote Execution?

It uses the resources of the other machine without using that system physically. Let's see the demo.

SSH(Secure Shell): - It is the protocol through which we can connect to the machine remotely.

Docker: - It is product through which we are using container technology.

Task: - We are going to setup the python server in docker centos container in which we can run our python programs.

Step 1: - Launch the docker container with centos image.

No alt text provided for this image

Step 2: - Now install the "openssh-server" program inside the container. Check how we can get this software by "yum whatprovides ssh" command shown in above photo.

Install by doing "yum install <software-name>".

No alt text provided for this image

To check software is available in your image command shown in above photo.

Step 3: - Now we need to start the ssh server in the image. for that we need to generate the ssh_hot_keys in the "/etc/ssh/" folder.

For, generation of these keys we can use command "/usr/bin/ssh-keygen -A" .

Now, we can use command "/usr/sbin/sshd" command to start the server.

You want to check it's running or not you can use "ps -ef" command. You can check it below.

No alt text provided for this image

Now you can exit from the image just note the ip of the container.

Step 4: - Install the "openssh-clients" software in your client system.

No alt text provided for this image

Step 5: - We can get whole system down here by following steps below.

No alt text provided for this image

Step 6: - Downloading the python in the python_server by performing commands below.

No alt text provided for this image

Step 7: - Copy the python code on the python server and you can run it using the resources of that system which is physically not available with you.

No alt text provided for this image

Here, you can see I have use "docker cp" command but command "scp <Source> <destination_ip:path>" also can be used.

Thank You.


To view or add a comment, sign in

More articles by Maharshi Prajapati

Others also viewed

Explore content categories