TEXT 26
Shell-ssh.txt Guest on 4th May 2021 07:00:57 PM
  1. Operating Systems and Systems Integration
  2.  
  3. Tutorial on Shell, and the Secure Shell 1 Shell Programming
  4. 1. What will this shell script do? Disuss the purpose of this script. #! /bin/sh if ! grep nickl /etc/passwd > /dev/null 2>&1 then useradd -c ’Nick (local)’ nickl fi if ! grep nickl /etc/sudoers > /dev/null 2>&1 then echo ’nickl ALL=(ALL) ALL’ >> /etc/sudoers fi 2. What will the output of this shell script be? #! /bin/sh i=2 for j in 2 4 6 do j=‘expr $i \* $j‘ i=‘expr $i + 1‘ done echo "i=$i j=$j" 3. Rewrite the script from question 2 above using a while loop. 4. Write a shell script to print all its parameters, each one on a line by itself. 5. Write a shell script to read a text file in a format like this: nicku:Nick Urbanik fred:Freddy Wong albert:Albert Ho and create user accounts for each user. Here is a strong hint towards getting a solution: $ cat reading-line-by-line-and-splitting #! /bin/sh while read line
  5. Nick Urbanik <nicku@vtc.edu.hk> ver. 1.1
  6.  
  7. Tutorial on Shell, and the Secure Shell Operating Systems and Systems Integration
  8.  
  9. 2
  10.  
  11. do echo "This is a line: $line" IFS=: for part in $line do echo This is part of the line: $part done done $ reading-line-by-line-and-splitting < ~/account-info.txt This is a line: nicku:Nick Urbanik This is part of the line: nicku This is part of the line: Nick Urbanik This is a line: fred:Freddy Wong This is part of the line: fred This is part of the line: Freddy Wong This is a line: albert:Albert Ho This is part of the line: albert This is part of the line: Albert Ho
  12.  
  13. 2
  14.  
  15. Secure Shell
  16. 1. The user keys are stored in ∼/.ssh/id rsa, ∼/.ssh/id rsa.pub and ∼/.ssh/authorized keys2. (a) Are these user keys required for ssh to enable remote log in? If not all, and if some are required, list the ones that are required. (b) What is the purpose of each one of these key files? (c) How do you create them, and if we have one client and one server computer, which keys are required where? 2. The host keys are stored in /etc/ssh/ssh host dsa key, /etc/ssh/ssh host dsa key.pub, ∼/.ssh/known hosts2 and /etc/ssh/ssh known hosts2. (a) Are all these host keys required for ssh to enable remote log in? If not all, and if some are required, list the ones that are required. (b) List two purposes of all of these key files. (c) How do you create them, and if we have one client and one server computer, which keys are required where?
  17.  
  18. Nick Urbanik <

Paste-bin is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.