DevOps session 13: Automate git SETUP using bash scripting.

Image
  Bash scripting: A Bash Shell Script is a plain text file containing a set of various commands that we usually type in the command line. It is used to automate repetitive tasks on Linux filesystem. It might include a set of commands, or a single command. For example ,to install GIT we need to update the packages, then install git and check if installation is done using Linux commands. We can write all the command in a .sh file and we can execute the file to do all the steps mentioned above. Lets start with example from hello-world. 1.Open terminal and check the root of the bash using below command. CMD: which bash you can see path like  /usr/bin/bash or /bin/bash . 2.Create a hello-world.sh file and paste the below lines. CMD: nano hello-world.sh You can see editor ,add below lines #!/bin/bash # declare MSG variable MSG="Hello World" # print variable on a screen echo $MSG To save the file use CTRL+X, then CTRL+Y and press ENTER 3. To execute the file we need to ad...

DevOps session 9: setup GITHUB SSH authentication

 


SSH is used to connect with remote systems and share the data safely, securely.


Advantages of using SSH Authentication:

1. Every time we need to provide the user and password when we are pushing the code from local to GitHub repo. To avoid this we can use SSH for authenticating directly and pushing the code.

2. Because we are not providing login credentials every time. We can save lots of time.

3. It is secure way to connect with local and central repo while transferring data.


Follow the below steps to setup SSH and connect your local repo ,central repo securely.

1. Open ubuntu terminal, and pass below command to generate key.

    cmd: ssh-keygen -o -t rsa -C "test@example.com"

    Then press enter 3 times, you can see a screen as below.


2. Once Key is generated,check in the .SSH folder.Follow below commands.

    cmd 1: cd ~/.ssh

    cmd 2: ls -a

    cmd 3: cat id_rsa.pub

Copy the key from the console.


3. Once public key is copied from console, Go to your GitHub account created in previous sessions. Login into your account.

4. Once logged in to your GitHub account, Go to settings and the find SSH and GPG keys. Then 


5. Click on New SSH and then provide SSH -key name and then  paste the public you copied from STEP -2 .Finally click on "Add SSH key" button. 




6. To verifying if the SSH is configured properly, we need to check the sample repo we created and then click SSH tab, to confirm if SSH is successful. No error should be displayed and a link will be shown to access the sample repo.




7.  Now we are ready to login into our GitHub repo using SSH authentication. 

you can use the SSH link from STEP 6 and clone using SSH now. Command provided below.



Comments

Popular posts from this blog

DevOps session 1: Evolution of Software development

DevOps session 10: Git basic commands for daily use