What do you someone breaks something? I post the solution here...

Kubernetes (K8s/K3d) / Terraform / Ansible / Linux / AWS / Docker / Bash / Python / ELK / CI/CD / Java / Traefik / Nginx / CentOs / Ubuntu


Password less Authentication on two Docker Containers




Password less Authentication on two Docker Containers



    Note : This article is reply to the question posted by Vijay Kumar Balaji

    
     Steps :
         
      
       1.Build a Docker Image from Dockerfile, create two Containers
       2.Setup Public and Private key
      

Lets Do it, I have used Azure Docker Virtual Machine,you can have your own 
docker setup.

It is pre-assumed that you know docker.



    

     

          1.Build a Docker Image, create two Containers

       Here i have used Dockerfile,you can also do it manually pulling a bare OS and set up SSH.


     Create a Dockerfile

                       vim Dockerfile
     


     
   write and quit.Lets build image from the docker file that is done as..
     
     docker build -t osgroup/ssh_machine1  .

 . means from the current directory.





    Creating first container
        
        docker run -tid osgroup/ssh_machine1

    we can run it twice to create two containers


    Checking the running containers
         
            docker ps


     Checking the IP assigned to containers

        docker inspect <container_name > | grep IPAddress


Getting Inside the first container

      docker exec -ti <container_name> bash



Checking with ssh and logging on second container with password

     ssh -l root <ip-address_of second container>



             2.Setup Public and Private key

We generated a public and private key pair on first machine 

    ssh-keygen


Copy the public key to the other machine
        
       ssh-copy-id  -i ~/.ssh/id_rsa.pub <ip_of_remote container>


That's all Done !!!!





Thanks Happy Virtualization !!!! Feel Free to post as may question possible we try to solve as much as we can 



1 comment:

Unknown said...

I read your Blog Your explanation is really good just check it once once Devops Online Training Hyderabad to Know more.

Powered by Blogger.