Hi @Tej-Singh-Rana,
Thank you for responding and thank you for the link. However, I believe that my situation is a bit
different then as discussed via the link.
I was able to copy the script over without having to enter a password. The script did not ask for password while copying the archive file because the first thing that I did (after SSHing over to App Server 1) was run:
ssh-keygen
ls -al ~/.ssh/
ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected]
Here are the steps that I took (in the order entered):
ssh tony@stapp01 //enter Tony's password
# from App Server 1
ssh-keygen
ls -al ~/.ssh/
ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected]
# From Backup server
ssh [email protected] //enter Clint's password
# check to see that key was successfully transferred over
cat /home/clint/.ssh/authorized_keys
# Back on App Server 1
# Login from App Server 1 to Backup Server without Password/check to see
# if login without password successful
ssh [email protected] //no prompt for password
exit
# back on App Server 1
sudo yum install zip
create script:
cd /scripts
sudo vi official_backup.sh
# add:
sudo zip -r xfusioncorp_official.zip /var/www/html/official
mv xfusioncorp_official.zip /backup/
cd /backup/
sudo scp xfusioncorp_official.zip clint@stbkp01:/backup/ //no password prompt, task successful
The only similarity to the link provided above is that I had sudo
prepended to a couple of my commands in the script. The error prompt, however, makes no mention of this being an issue when my task was marked as failed.
make script executable
sudo chmod u+x official_backup.sh
sudo chmod 744 official_backup.sh
# run script
sudo ./official_backup.sh
File was successfully copied over without having to enter a password.
Therefore, I simply cannot see how my task was marked as being incorrect…again, because even with the use of the word sudo
, there is no mention of that being an issue in the error/fail output. It instead tells me that my file has not been saved to /backup/
.
PS.
I have just gone over the link that you provided a second time…
The thing is that even though I had sudo
prepended to a couple of the commands in
the script, the script was still copied over successfully without having to enter in a password.
The error prompt is incorrect in stating that I have not successfully copied over the script
to the /backup/
directory.
Thanks again for your time.
PSS ( ):
In this link https://kodekloud.com/community/t/linux-bash-scripts-task-failed/10756
it is mentioned that you have to perform this task from their respective sudo user not from root user. In my case, I did perform the task from the respective sudu user (tony@stapp01 in my case), so I know that this is not the reason
for my task being marked as incorrect.