Lab 06: Linux Remote Service

Goals

Credits

The work is based on labs and exercises from previous offerings of CSCI 363.

Introduction

In this lab you will create a pair of programs that mimic the behavior of Linux login server and client. You will be given a set of source programs as a starting point. One of the programs, login.c asks the user to enter a user name and a corresponding password. The program checks the validity of the user name and password against a given database. If the user name and password matches properly, the program starts a user shell with which the user can do any Linux work. The other two programs are a pair of remote login client and server rshClient.c and rshd.c, some of the functions are implemented in a separate file called rsh.c. This set of programs allow a user to remote log into a server without any authentication. Your task is to try these programs first, then read the programs to understand the process. Finally you will revise the programs such that the remote login server will ask for user name and password for authentication. Only the users with proper credentials can log onto the remote server.

Exercises before Programming

You first do the following to gain some first-hand experiences.

Some Background Information

We describe some basic ideas here. There are three major components in this set of programs.

Your Work

You will develop a set of remote login service program using the two existing pairs of programs. You should have a client program that will take the user name and password on the local machine. The client program then sends the pair of user name and password to the remote machine (server). The remote login service should check the validity of the user name and password combination. If the user is valid, the program provides a shell service to the remote client. If the user is invalid, the program simply ignores the request and prompt the user for next trial if so chose by the user, just like any Linux systems would do. The user credential files passwd and shadow reside on the server side.

Revise the server/client to check user name and password

Your first task is to revise the server (rshd.c and rsh.c) and client (rshClient.c) such that your client program and the server program can run on two different Linux computers with user name and password checking. You will have to add the part of the logic in login.c that reads user name and password into rshClient.c at proper place. You also need to add the part of the logic in login.c that check the user name and password to the server rshd.c and rsh.c at proper place.

Note that at this point the user name and password sent to the remote server are in plain text. So the service is not secure. In order to make a secure service, we need to use Secure Sockets Layer or SSL protocol, which we will explore later in the semester.

Revise the server to run on your VM

After you make the programs work properly on our local Linux machines, you are asked to revise the programs to run the server program on your VM so the program can access a set of user names and passwords on the VM. You have to complete two separate sets of tasks to make the programs work.

First, you need to change the firewall set-ups on the VM side such that the server program can run on the VM at a particular port.

Next you need to revise the rshd program so it will use the real getspnam() function in the Linux system. Notice that in your current program, the function getspnam() is custom developed to mimic the behavior of the system function with the same name. The reason for doing so is that your program usually runs from user space that doesn't have the privilege of reading user information. But when running on your VM as the root user, the program has access to these real data. Thus you can use real system calls to access these information. The following is what you need to do.

Now you should be able to compile the program by simply doing a make. Fix any errors you might have. Then run rshd on the VM.

With the server (rshd) running on the VM, you can compile and run your client on any other Linux computers and the pair of programs should allow you to log into the VM from local Linux machine, and work in a way similar to ssh.

When all is working well on the VM side, please copy all program files, including the Makefile back to your Linux side. Put them in the subdirectory native. You are asked to submit this set of files as well.

What to submit

You are asked to commit and push all program files in your lab06 and its subdirectory native.

In addition, create an answer.txt file. Include four sets of screen outputs, using copy-and-paste, or script. Please label these output files with the following number with a proper title.

  1. Screen output of compiling the programs on the Linux side with make.
  2. Screen output of compiling the programs on the VM side with make.
  3. Screen output of running the client with the server running on a Linux machine.
  4. Screen output of running the client with the server running on your VM.

Congratulations! You just finished this lab.