Enable SSH & Telnet Server On Ubuntu Linux

Suppose we have a computer with Ubuntu Linux installed. If we want to access this computer remotely through SSH protocol, we must enable SSH server first. To enable SSH server on Ubuntu Linux, we must install openssh-server package first :

tedy@tedy-laptop:~$ sudo apt-get install openssh-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libwxgtk2.8-0 kdebase-data kicker libkonq4 libwxbase2.8-0
Use 'apt-get autoremove' to remove them.
Suggested packages:
  molly-guard rssh
The following NEW packages will be installed:
  openssh-server
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0B/252kB of archives.
After this operation, 668kB of additional disk space will be used.
WARNING: The following packages cannot be authenticated!
  openssh-server
Install these packages without verification [y/N]? y
Preconfiguring packages ...
Selecting previously deselected package openssh-server.
(Reading database ... 199826 files and directories currently installed.)
Unpacking openssh-server (from .../openssh-server_4.7p1-8ubuntu1_i386.deb) ...
Setting up openssh-server (1:4.7p1-8ubuntu1) ...
Creating SSH2 RSA key; this may take some time ...
Creating SSH2 DSA key; this may take some time ...
 * Restarting OpenBSD Secure Shell server sshd                           [ OK ]

After install the package, the sshd daemon will run automatically. We can check the status of the SSH daemon by using check the process and port, SSH server by default listen on port 22 :

tedy@tedy-laptop:~$ ps -ef | grep sshd
root      8228     1  0 08:37 ?        00:00:00 /usr/sbin/sshd
tedy      8248  7815  0 08:38 pts/2    00:00:00 grep sshd
tedy@tedy-laptop:~$
tedy@tedy-laptop:~$ netstat -an | grep LISTEN | grep :22
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp6       0      0 :::22                   :::*                    LISTEN
tedy@tedy-laptop:~$

To restart SSH daemon we use the following command (need root priviledge to do that) :

root@tedy-laptop:/home/tedy# /etc/init.d/ssh restart
 * Restarting OpenBSD Secure Shell server sshd                           [ OK ]
root@tedy-laptop:/home/tedy# /etc/init.d/ssh restart

Below is the output example when trying to do SSH on that machine :

login as: tedy
tedy@10.191.75.201's password:
Linux tedy-laptop 2.6.32-21-generic #32-Ubuntu SMP Fri Apr 16 08:10:02 UTC 2010 i6                                                                              86 GNU/Linux
Ubuntu 10.04 LTS

Welcome to Ubuntu!
 * Documentation:  https://help.ubuntu.com/

Last login: Tue Jan  4 22:54:26 2011 from mytestbed.local
tedy@tedy-laptop:~$

As you can see on above example, Ubuntu show last login display everytime we access it using SSH. To prevent Ubuntu display last login info when somebody login into the system using SSH, we can edit /etc/ssh/sshd_config and set PrintLastLog parameter to NO.

tedy@tedy-laptop:~$ cat /etc/ssh/sshd_config
....
....
X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog no
TCPKeepAlive yes
UseLogin yes
....
....
#MaxStartups 10:30:60
Banner /etc/issue.net

Besides SSH, Ubuntu can be accessed through telnet protocol as long as it has telnet server running. To install telnet server on Ubuntu (package name is telnetd) we do it like this :

root@vpn-test:/home/tedy# apt-get install telnetd
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
openbsd-inetd
The following NEW packages will be installed:
openbsd-inetd telnetd
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 0B/76.9kB of archives.
After this operation, 283kB of additional disk space will be used.
Do you want to continue [Y/n]? Y
WARNING: The following packages cannot be authenticated!
openbsd-inetd telnetd
Install these packages without verification [y/N]? y
Selecting previously deselected package openbsd-inetd.
(Reading database ... 99838 files and directories currently installed.)
Unpacking openbsd-inetd (from .../openbsd-inetd_0.20050402-6_i386.deb) ...
Selecting previously deselected package telnetd.
Unpacking telnetd (from .../telnetd_0.17-35ubuntu1_i386.deb) ...
Setting up openbsd-inetd (0.20050402-6) ...
* Stopping internet superserver inetd [ OK ]
* Not starting internet superserver: no services enabled.

Setting up telnetd (0.17-35ubuntu1) ...
Adding user telnetd to group utmp

root@vpn-test:/home/tedy#

To check the availability of telnet server we can check the by using this command (remember that telnetd process listen on port 23 by default):

root@vpn-test:/home/tedy# netstat -an | grep LISTEN | grep ":23 "

tcp        0      0 0.0.0.0:23              0.0.0.0:*               LISTEN     

root@vpn-test:/home/tedy#

Below is the output example when trying to do telnet on that machine :

Ubuntu 10.04 LTS
vpn-test login: tedy
Password:
Last login: Wed Jan  5 11:24:44 WIT 2011 from dhcp-id-jakata-10-181-190-235.id.oracle.com on pts/0
Linux vpn-test 2.6.32-21-generic #32-Ubuntu SMP Fri Apr 16 08:10:02 UTC 2010 i686 GNU/Linux
Ubuntu 10.04 LTS

Welcome to Ubuntu!
 * Documentation:  https://help.ubuntu.com/

tedy@vpn-test:~$

9 thoughts on “Enable SSH & Telnet Server On Ubuntu Linux

  1. Hi I tried to run :sudo apt-get install openssh-server but I got the error : unable locate package
    , my ubuntu laptop has internet connection, pls help me to solve this

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.