Linux Bash Scripts - task failed

Hi,
Something is wrong with this scenario. I made script that passwordless copy zipped directory form stapp03 to backup server. I checked if it copied right, and still got failed.

[email protected] scripts]# ssh-keygen -t rsa

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:XPHlScAFcL0ymluDqV/+tjV8mfZGLb5E2moKo5XQ7iM [email protected]
The key’s randomart image is:
±–[RSA 2048]----+
| oo+=+ |
| +.+… |
| . . o. |
| o . o . |
| . S = o. .|
| o .= o+o =|
| *. ooooOo|
| E+oo.o.o+.=|
| …ooooo++.|
±—[SHA256]-----+
[[email protected] scripts]# 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:CgV5OvTrQuqVlZyah+PDsjjVlQEG1I5hyuyNhDy+Iio.
ECDSA key fingerprint is MD5:15:f0:cc:60:e0:43:3e:ed:e6:d3:3a:be:03:e2:64:96.
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] scripts]# vi news_backup.sh
[[email protected] scripts]# ./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 1.2MB/s 00:00
[[email protected] scripts]# ls -al
total 12
drwxrwxrwx 2 root root 4096 May 20 13:15 .
drwxr-xr-x 1 root root 4096 May 20 13:10 …
-rwxr-x— 1 root root 127 May 20 13:15 news_backup.sh
[[email protected] scripts]# ssh ^C
[[email protected] scripts]# ssh [email protected]
[[email protected] ~] ls /backup/ xfusioncorp_news.zip [[email protected] ~] exit
logout
Connection to stbkp01 closed.
[[email protected] scripts]# ./news_backup.sh
updating: var/www/html/news/ (stored 0%)
updating: var/www/html/news/.gitkeep (stored 0%)
updating: var/www/html/news/index.html (stored 0%)
xfusioncorp_news.zip 100% 588 958.8KB/s 00:00
[[email protected] scripts]# ls -al
total 12
drwxrwxrwx 2 root root 4096 May 20 13:15 .
drwxr-xr-x 1 root root 4096 May 20 13:10 …
-rwxr-x— 1 root root 127 May 20 13:15 news_backup.sh
[[email protected] scripts]# ls /backup/
xfusioncorp_news.zip
[[email protected] scripts]# ls -al /backup/
total 12
drwxrwxrwx 2 root root 4096 May 20 13:15 .
drwxr-xr-x 1 root root 4096 May 20 13:10 …
-rw-r–r-- 1 root root 588 May 20 13:15 xfusioncorp_news.zip
[email protected]_host /$

Will I recieve any response, to that issue?

Regards,
Damian

the error you made is while you were trying to setup the passwordless for root user not for tony user
so you must run cmds banner
[email protected] # sudo ssh-copy-id [email protected]” that’s way you will create a key and setup passwordless for banneruser and not for root.