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.
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>".
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.
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.
Step 5: - We can get whole system down here by following steps below.
Step 6: - Downloading the python in the python_server by performing commands below.
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.
Here, you can see I have use "docker cp" command but command "scp <Source> <destination_ip:path>" also can be used.
Thank You.