Monday, June 17, 2013

Session 1: Secure Shell (ssh)

OVERVIEW
The activity today comprises of the introduction to data communications and networking using the Secure Shell (ssh) to connect to a remote server. SSH can be used to access a remote computer or a server by using a terminal. The Internet Protocol address or IP address of the said server should be known, so that a local computer can access it. 

PROBLEM STATEMENT
The students need to connect to a remote computer via a terminal using the ssh commands.

GUIDES ON SOLVING THE PROBLEM
The following are the steps needed to perform in order to connect to a server using ssh commands.

Adding a User to a Local Computer

Adding a user to a local computer
The screenshot shows that a user is successfully added to a local computer.
STEPS:
1. Create a username and password for the new user.
2. Type the command $sudo adduser <created username>.
3. Type the password of the local computer where the new user will be added.
4. The terminal will ask the user for its password.
5. The terminal will prompt the user that the user is added and ask for its personal information.
6. Confirm if the information is correct.
The steps specified and the screenshot allow the user to add a new user to a local computer.


Connect to a Remote Computer or Server via 'ssh' Commands

To connect to remote computer (server), you need to have a username and password created in adding a user to a local host. the username and password are needed to login in the remote computer using ssh commands. Also, the IP address of the remote computer is needed so that a user can access it since its IP address is different with the local computer you are using.
Connect to a remote computer using a ssh command
The screenshot above shows what the command on how to connect to a remote computer, and the output when a connection is established.
STEPS:
1. Login using your new account. Type the command $su <username>.        

2. The terminal will ask for your password. If the password is correct, the terminal will show the name  of the user and the directory in use. In the case of the screenshot, it displays "rmqarellano@ics-user:/home/ics-user$".
3. After logging-in, use the command $ssh 172.16.7.88 to connect to the remote computer. 172.16.7.88 is the IP address of a server in ITC.
4. The terminal will ask if you want to continue connecting to the server.
5. The terminal will ask for your password.
6. When the connection is established, the name in the terminal should change to "rmqarellano@paho:~$" as stated in the screenshot.



Configuring a Local Computer for a Passwordless Log-in
It is possible that when accessing the remote computer, a password is not needed to log-in, only the username is needed. The following steps and the screenshot will lead your way :).
Generating public/private key
STEPS:
1. Logout form the remote computer using the command $su <username>.
2. Go to the home directory of the local computer and search for the .ssh directory under your home folder. Go to that directory.
3. After changing to that directory, type the following commands:
                  $ssh-keygen -t rsa
                  $<enter>
                  $<enter>
                  $<enter>
             The terminal will show the key fingerprint.
Passwordless login
4. To use a secure copy (scp) to your home folder, use either of the following commands:
                  $ scp id_rsa.pub username@172.16.7.88:~/.ssh/authorized_keys
                  or
                  $ssh-copy-id username@172.16.7.88
5. Try to login again to the remote computer using your username. Notice that the terminal didn't ask for your password. :)


Broadcasting a Message using the 'wall' Command

Once the user is able to connect to a remote computer, he/she can send a message to the server where the other users can see. This can be done via the broadcast message using the wall command.
Broadcasting a message using the wall command
The screenshot shows how to broadcast a message when connected to a remote computer. The following steps will help the user to perform this task.
STEPS:
1. Type the command $mesg. make sure that it is set to yes (output is "y").
2. If mesg is set to yes, you can now use the wall command to broadcast a message. You can use the following commands fro broadcasting:
                       $wall <<< "<message>"
                       $echo "<message>" | wall
                       $wall [filename]
3. Use CTRL+D to terminate the wall.
         

Sending a Message to a Particular Local Host using 'write' Command

Aside from broadcasting a message where all users can see the message, you can also send a message to a particular user (much like a chat :D). This can be done using the write command.
Conversation with another user using the write command
This screenshot shows the how to communicate with a fellow user using the write command.
STEPS:
1. Get the username of the user you want to talk/chat with. Type the command $write <username of other user> [enter]. You should write your message after you click the ENTER key.
2. Use CRTL+D to terminate the conversation.


LEARNING AND INSIGHTS
The passwordless log-in is only possible to a particular local computer. In other words, if you use another local computer to access the remote server, it would not be passwordless because each local computer has its own IP address and public/private key. Using another local computer and use your login account from a different local computer is not possible.


CONCLUSION In this activity, the students learn how to connect to a remote computer (server), log-in without using a password, broadcast message, and send a message to a particular local host. The students perform the needed steps or guides necessary to solve the problem.


This should wrap-up the first session of our laboratory on data communications and networking :)

No comments:

Post a Comment