Linux BAsh Script

Why it failed? @Inderpreet

This forum can be really helpful if you have more evidences of your work and you would get immediate responses.

  1. Question asked
  2. Actions you performed.

If you missed to have the screenshots, ofcourse you have to reach kodekloud support to verify the logs for your work.

Thank you

1 Like

@manpreetiitm89 You created and tested your script using user root but as per task requirements it was supposed to be done using sudo user only . (i.e tony for app server 1)

Screenshot from your answer
Screenshot from 2020-09-12 12-05-56

Thnku will try when its reassigned.

@Inderpreet
I have performed the steps as mentioned below script

and also checked the backup dir in stbkp01 server

my username: aashiqahamedsp@gmail.com

can you help me why the task failed.

@Inderpreet @player001 If you can see my logs,

I ran the script with below commands

cd /scripts
sudo chmod 777 ecommerce_backup.sh
./ecommerce_backup.sh

as you can see my script is above screenshot.

for scp i generated ssh keys as below -

ssh-keygen
ssh-copy-id clint@stbkp01

I did not used root user anywhere or sudo

especially to run the script and ssh-keygen or scp is done with app user itself

@Inderpreet @player001 please check and help

Can you share the error message also? @Aashiqahamed

Hi @player001
Below is the error message i recieved saying the task is failed

@Inderpreet @KodeKloud can anyone help with above, why my task failed, i have not used sudo to run the script file and also have password-less access to backup server from user steve@stapp02

Hi team @KodeKloud @Inderpreet can anyone help me on this!!

@ashiqponani , For the task I have added zip and scp in sudoers file, did you do that too?

If you look at the entire post, another person had the same problem and it was about root privileges. " the user must have access to run the script without password"

@Nasri No i have not modified anything in /etc/sudoers

As you can see my script above my scp command is stated without sudo and for zip i gave sudo i don’t think that failed the task because ultimately my whole script ran without sudo and without password

and just before submitting the final task i had a network glitch for 2-3 seconds later connection retrieved automatically once i submitted the task

@Aashiqahamed in the first picture you were using cat with sudo and you entered password for user “steve”, I think that password has been saved for the entire ssh session and run the script without prompting any password.
I may be wrong.

@Nasri may be but anytime once SSH into any server and try to do run any command with sudo for first time the server will prompt for password and later it won’t

But the above screenshot is captured after failing the task to show my script and its not while submitting the task.

@Aashiqahamed let’s help from @Inderpreet

yes @Inderpreet please help with my task