Linux Bash Scripts task

how to verify if all the steps are done correctly for this task?

  1. running the script from root is causing failure, will run it from tony/steve/banner user

ssh [email protected]
The authenticity of host ‘stapp03 (172.16.238.12)’ can’t be established.
ECDSA key fingerprint is SHA256:SySamszyWhhLGFiybhGBqfrr8g55wS/3e37ZpBOvICs.
ECDSA key fingerprint is MD5:6d:31:18:2a:f9:07:f3:29:dd:0a:d3:1f:6e:04:0a:db.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘stapp03,172.16.238.12’ (ECDSA) to the list of known hosts.
[email protected]’s password:
[[email protected] ~]$ sudo su

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

[sudo] password for banner:
[[email protected] banner]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory ‘/root/.ssh’.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:GiGNRFTipX1/MzxFOr8TAPARnumj7/QBhZEXV9dlrog [email protected]
The key’s randomart image is:
±–[RSA 2048]----+
| o=.o …=o…o.B|
| o B o.B.+ oo|
| = + . *.= . .|
| . o o + * . |
| . S E B + |
| o . + + o |
| . . . . o |
| o . . . |
| .o . |
±—[SHA256]-----+
[[email protected] banner]# ssh-copy-id [email protected]
/bin/ssh-copy-id: INFO: Source of key(s) to be installed: “/root/.ssh/id_rsa.pub”
The authenticity of host ‘stbkp01 (172.16.238.16)’ can’t be established.
ECDSA key fingerprint is SHA256:00s+COQ/Ir0HFI4OX2RwOj5xkHbXMFE/ApAj/SjSlYU.
ECDSA key fingerprint is MD5:7b:2c:ce:24:03:c6:e3:0a:f0:d9:1a:42:6b:76:6f:42.
Are you sure you want to continue connecting (yes/no)? yes
/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed – if you are prompted now it is to install the new keys
[email protected]’s password:

Number of key(s) added: 1

Now try logging into the machine, with: “ssh ‘[email protected]’”
and check to make sure that only the key(s) you wanted were added.

[[email protected] banner]# vi news_backup.sh
[[email protected] banner]# ./news_backup.sh
bash: ./news_backup.sh: Permission denied
[[email protected] banner]# cd scripts
bash: cd: scripts: No such file or directory
[[email protected] banner]# mkdir /scripts
mkdir: cannot create directory ‘/scripts’: File exists
[[email protected] banner]# cd /scripts
[[email protected] scripts]# ls -al
total 8
drwxrwxrwx 2 root root 4096 Aug 18 02:22 .
drwxr-xr-x 1 root root 4096 Aug 18 02:22 …
[[email protected] scripts]# cd …
[[email protected] /]# cd banner
bash: cd: banner: No such file or directory
[[email protected] /]# vi news_backup.sh
[[email protected] /]# cd /scripts/scripts
bash: cd: /scripts/scripts: No such file or directory
[[email protected] /]# /cd /scripts
bash: /cd: No such file or directory
[[email protected] /]# cd /scripts
[[email protected] scripts]# vi news_backup.sh
[[email protected] scripts]# chmod +x news_backup.sh
[[email protected] scripts]# sh news_backup.sh
adding: var/www/html/news/ (stored 0%)
adding: var/www/html/news/.gitkeep (stored 0%)
adding: var/www/html/news/index.html (stored 0%)
xfusioncorp_news.zip 100% 588 799.4KB/s 00:00
[[email protected] scripts]# ls -al
total 12
drwxrwxrwx 2 root root 4096 Aug 18 02:38 .
drwxr-xr-x 1 root root 4096 Aug 18 02:35 …
-rwxr-xr-x 1 root root 123 Aug 18 02:38 news_backup.sh
[[email protected] scripts]# ssh [email protected]
[[email protected] ~] ls /backup/ xfusioncorp_news.zip ls: cannot access xfusioncorp_news.zip: No such file or directory /backup/: xfusioncorp_news.zip [[email protected] ~] ls /backup/
xfusioncorp_news.zip
[[email protected] ~] ls -al /backup/ total 12 drwxrwxrwx 2 root root 4096 Aug 18 02:39 . drwxr-xr-x 1 root root 4096 Aug 18 02:22 .. -rw-r--r-- 1 clint clint 588 Aug 18 02:39 xfusioncorp_news.zip [[email protected] ~] exit
logout
Connection to stbkp01 closed.
[[email protected] scripts]# exit
exit
[[email protected] ~] exit logout Connection to stapp03 closed. [email protected]_host / ssh [email protected]
The authenticity of host ‘stbkp01 (172.16.238.16)’ can’t be established.
ECDSA key fingerprint is SHA256:00s+COQ/Ir0HFI4OX2RwOj5xkHbXMFE/ApAj/SjSlYU.
ECDSA key fingerprint is MD5:7b:2c:ce:24:03:c6:e3:0a:f0:d9:1a:42:6b:76:6f:42.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘stbkp01,172.16.238.16’ (ECDSA) to the list of known hosts.
[email protected]’s password:
Permission denied, please try again.
[email protected]’s password:
Last login: Tue Aug 18 02:40:49 2020 from stapp03
[[email protected] ~]$ sudo -i

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

[sudo] password for clint:
[[email protected] ~]# ls /backup/
xfusioncorp_news.zip
[[email protected] ~]# exit
logout
[[email protected] ~] exit logout Connection to stbkp01 closed. [email protected]_host / ssh [email protected]
[email protected]’s password:
Last login: Tue Aug 18 02:44:59 2020 from jump_host.linuxbashscripts_app_net
[[email protected] ~] ls /backup/ xfusioncorp_news.zip [[email protected] ~] exit
logout
Connection to stbkp01 closed.
[email protected]_host / ssh [email protected] [email protected]'s password: Last login: Tue Aug 18 02:50:15 2020 from jump_host.linuxbashscripts_app_net [[email protected] ~] ssh [email protected]
The authenticity of host ‘stapp02 (172.16.238.11)’ can’t be established.
ECDSA key fingerprint is SHA256:SySamszyWhhLGFiybhGBqfrr8g55wS/3e37ZpBOvICs.
ECDSA key fingerprint is MD5:6d:31:18:2a:f9:07:f3:29:dd:0a:d3:1f:6e:04:0a:db.
ECDSA key fingerprint is SHA256:SySamszyWhhLGFiybhGBqfrr8g55wS/3e37ZpBOvICs.
ECDSA key fingerprint is MD5:6d:31:18:2a:f9:07:f3:29:dd:0a:d3:1f:6e:04:0a:db.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘stapp03,172.16.238.12’ (ECDSA) to the list of known hosts.
[email protected]’s password:
Last login: Tue Aug 18 02:24:42 2020 from jump_host.linuxbashscripts_app_net
[[email protected] ~] cd /scripts [[email protected] scripts] sh news_backup.sh
zip I/O error: Permission denied
zip error: Could not create output file (/backup/xfusioncorp_news.zip)
The authenticity of host ‘stbkp01 (172.16.238.16)’ can’t be established.
ECDSA key fingerprint is SHA256:00s+COQ/Ir0HFI4OX2RwOj5xkHbXMFE/ApAj/SjSlYU.
ECDSA key fingerprint is MD5:7b:2c:ce:24:03:c6:e3:0a:f0:d9:1a:42:6b:76:6f:42.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘stbkp01,172.16.238.16’ (ECDSA) to the list of known hosts.
[email protected]’s password:
xfusioncorp_news.zip 100% 588 773.7KB/s 00:00
[[email protected] scripts]$