Book Image

Linux Shell Scripting Bootcamp

By : James K Lewis
Book Image

Linux Shell Scripting Bootcamp

By: James K Lewis

Overview of this book

Linux Shell Scripting Bootcamp is all about learning the essentials of script creation, validating parameters, and checking for the existence of files and other items needed by the script. We will use scripts to explore iterative operations using loops and learn different types of loop statements, with their differences. Along with this, we will also create a numbered backup script for backup files. Further, you will get well-versed with how variables work on a Linux system and how they relate to scripts. You’ll also learn how to create and call subroutines in a script and create interactive scripts. The most important archive commands, zip and tar, are also discussed for performing backups. Later, you will dive deeper by understanding the use of wget and curl scripts and the use of checksum and file encryption in further chapters. Finally, you will learn how to debug scripts and scripting best practices that will enable you to write a great code every time! By the end of the book, you will be able to write shell scripts that can dig data from the web and process it efficiently.
Table of Contents (19 chapters)
Linux Shell Scripting Bootcamp
About the Author
About the Reviewer
Customer Feedback

ssh and scp

Using scp to a remote computer is a really good idea too and my backup program does that every night as well. Here is how to set up unattended ssh/scp. In this case, the root account on machine 1 (M1) will be able to scp files to the guest1 account on machine 2 (M2). I do it this way because I always disable root access of ssh/scp for security reasons on all my machines.

  1. First make sure ssh has been run at least once on each machine. This will set up some needed directories and files.

  2. On M1, under root, run the ssh-keygen -t rsa command. This will create the file in the /root/.ssh directory.

  3. Use scp to copy that file to M2 to the /tmp directory (or some other suitable location).

  4. On M2 go to the /home/guest1/.ssh directory.

  5. If there is already an authorized_keys file edit it, otherwise create it.

  6. Copy the line in the /tmp/ file into the authorized_keys file and save it.

Test this by using scp to copy a file from M1 to M2. It should work without prompting for a password...