Sunday, 11 May 2014

Install and configure Telnet Server in Linux

Telnet service is to provide a text-oriented communications and this service is used on internet/LAN using a virtual terminal connection. Telnet by default uses 23 port number. We will use telnet server installation and configurations on CentOS 6 / Red Hat family as this service is also applicable and works to fedora distribution environment.
IP Configuration ( My Server IP address is 172.16.41.82 )

Telnet Server Configuration

Open Terminal and login as root user.
Install Telnet server using yum.
[root@linuxpathfinder /]# yum install telnet telnet-server

Setting up Install Process
 Resolving Dependencies
 --> Running transaction check
 ---> Package telnet.i686 1:0.17-47.el6_3.1 will be installed
 ---> Package telnet-server.i686 1:0.17-47.el6_3.1 will be installed
 --> Processing Dependency: xinetd for package: 1:telnet-server-0.17-47.el6_3.1.i686
 --> Running transaction check
 ---> Package xinetd.i686 2:2.3.14-39.el6_4 will be installed
 --> Finished Dependency Resolution

Dependencies Resolved
==================================================================
 Package               Arch     Version           Repository Size
 =================================================================
 Installing:
 telnet               i686     1:0.17-47.el6_3.1  base       57 k
 telnet-server        i686     1:0.17-47.el6_3.1  base       36 k
 Installing for dependencies:
 xinetd               i686     2:2.3.14-39.el6_4  updates    122 k

Transaction Summary
 =================================================================
 Install       3 Package(s)

Total download size: 215 k
 Installed size: 413 k
 Is this ok [y/N]:

Press [y] to complete the installation.

Installed:
 telnet.i686 1:0.17-47.el6_3.1
 telnet-server.i686 1:0.17-47.el6_3.1

Dependency Installed:
 xinetd.i686 2:2.3.14-39.el6_4

Complete!
Need to configure telnet server, go to the directory /etc/xinetd.d to change configuration.
[root@linuxpathfinder /]# cd /etc/xinetd.d
Using vim editor to edit the telnet file.
[root@linuxpathfinder xinetd.d]# ls

chargen-dgram   daytime-dgram   discard-dgram   echo-dgram   tcpmux-server  time-dgram
 chargen-stream  daytime-stream  discard-stream  echo-stream  telnet   time-stream
Change option ‘disable = yes’ to ‘disable = no’.
 # default: on
 # description: The telnet server serves telnet sessions; it uses \
 #       unencrypted username/password pairs for authentication.
 service telnet
 {
 flags           = REUSE
 socket_type     = stream
 wait            = no
 user            = root
 server          = /usr/sbin/in.telnetd
 log_on_failure  += USERID
 disable         = no
 }
Restart the service after change in the file and permanently save the changes by using chkconfig option.
[root@linuxpathfinder xinetd.d]# service xinetd restart

Stopping xinetd:              [  OK  ]
Starting xinetd:              [  OK  ]

[root@linuxpathfinder xinetd.d]# chkconfig xinetd on
Check out the firewall settings for further configuration:
[root@linuxpathfinder /]# setup
telnet-server-01
Enable the firewall settings and add telnet port 23 and Protocol is tcp.
telnet-server-02telnet-server-03telnet-server-04telnet-server-05telnet-server-08
Again restart the xinetd service after firewall settings.
[root@linuxpathfinder /]# service xinetd restart


Telnet Client Configuration

On the client end, you have to know the IP address of the remote server to access via telnet remotely. Remote communication with Telnet is insecure between server and client. For the secure communication use ssh service as explained already in previous tutorials.
Open Terminal and use the command telnet <server ip address>
Now put the username and password to access the remote system. (Login name : asifark)
Note : You cannot directly login as a super user in telnet.
[root@linux-server ~]# telnet 172.16.41.82

Trying 172.16.41.82...
 Connected to 172.16.41.82.
 Escape character is '^]'.
 CentOS release 6.4 (Final)
 Kernel 2.6.32-358.18.1.el6.i686 on an i686
 login: asifark
 Password:
 Last login: Wed Sep 30 14:44:14 from 172.16.41.82
 [asifark@linuxpathfinder ~]$ ls
 history_file.txt
 [asifark@linuxpathfinder ~]$ logout
 Connection closed by foreign host.
 [root@linux-server ~]#

How to Recover Linux Root Password

If you forget your linux server or client machine root password. Don’t you worry about this! in this tutorial it will explain with steps how you can reset it in simple way.
However, there are couple of methods to recover root password. So, lets go towards the easy and simple method I usually follow to recover my root user password in linux whenever I forget the password.
  • Save and close all your applications if you have opened already for safe data before reboot the machine.
  • Softly reboot your desktop client or server and wait for appearing a GRUB loader appearing.
  • When grub loader will be appeared, press “e” to edit into grub loader
root-password-01
  • Press arrow key and point to kernel line and then press “e” to edit into kernel
root-password-02
  • After that at the end of the kernel line and type “single” (without quotes) after give single space as shown below in the screenshot. and press “Enter” now.
root-password-03
  • Press “b” to boot after changes
root-password-04
  • Now you will get the root prompt without asking password
root-password-05
  • Reset the “root” password now.

How to Show Date and Time in the Terminal

Introduction

terminal-01In this tutorial we will talk about how to show date and time in the terminal. By default, the “prompt” or terminal displays the user name with which we are connected, the machine name and the path where it is located. As follows:
data-time-terminal-02
So we see here that the prompt is “<username> @ <machinename>: <path>”.
Note: When the user is in his home, the path is replaced by a tild (“~”).
In this tutorial we will see how to change the appearance of the prompt to display the time, date, or other characters.

Procedure

We must first understand that the form display prompt is specific to each user defined in the environment variable “PS1″ initialized to start a session. We can check the value of the environment variable “PS1″ with the following command:
[root@localhost usr]# echo $PS1
Then we have the following result:
data-time-terminal-03
We can therefore understand that:
“\U” = user
“@”: The symbol at sign
“\H” = the name of the machine
“\W”: the current path
“$” Sign dollars
Knowing this, we can freely change the appearance of our prompt. This requires that the time and date can be placed with the characters “\ t” for the time (“time”) and (“date”) “\ d” for the date. We can change the value of “PS1″ to add these characters with the following command:
[root@localhost usr]# PS1=’\d\t\u@\h:\W$’
We will immediately after a prompt like this:
You can of course change the display order of elements at will.

Make the Change Permanent

Since we have only changed the environment variable, this change will only be temporary. Indeed, restart another session, the environment variable will be reset. For the change to be permanent for the user must add our line to change the PS1 variable in the initialization of bash file with the following command:
[root@localhost usr]# echo “PS1=’\d\t\u@\h:\W$’” >> ~/.bashrc
Then restart a session for verification. To make this change permanent same for all users, you must make the same change on the common bash initialization file for all users:
[root@localhost usr]# echo “PS1=’\d\t\u@\h:\W$’” >> /etc/bash.bashrc
Hope, this tutorial will informative for you. Enjoy!