Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.82 KB | None | 0 0
  1. Disclaimer:
  2. Before installing and using Telnet, keep the following in mind.
  3.  
  4. Using Telnet in public network(WAN) is very very bad idea. It transmits login data in the clear format. Everything will be sent in plain text.
  5. If you still need Telnet, It is highly recommended use it in the local area network only.
  6. Alternatively, you can use SSH. But make sure you’ve disabled root login in SSH.
  7. What Is Telnet?
  8. Telnet is a network protocol which is used to connect to remote computers over TCP/IP network. Once you establish a connection to the remote computer, it becomes a virtual terminal and will allow you to communicate with the remote host from your local system.
  9.  
  10. In this brief tutorial, let us see how to install Telnet, and how to access remote systems via Telnet.
  11.  
  12. Installation
  13. Open your terminal and type the following command to install telnet:
  14.  
  15. yum install telnet telnet-server -y
  16. Now, the telnet has been installed in your server. Next, edit the telnet configuration file /etc/xinetd.d/telnet;
  17.  
  18. vi /etc/xinetd.d/telnet
  19. Set disable = no:
  20.  
  21. # default: on
  22. # description: The telnet server serves telnet sessions; it uses \
  23. # unencrypted username/password pairs for authentication.
  24. service telnet
  25. {
  26. flags = REUSE
  27. socket_type = stream
  28. wait = no
  29. user = root
  30. server = /usr/sbin/in.telnetd
  31. log_on_failure += USERID
  32. disable = no
  33. }
  34. Save and quit the file. Be mindful that you don’t have do this step in CentOS 7.
  35.  
  36. Now restart the telnet service using the following command:
  37.  
  38. On CentOS 6.x systems:
  39.  
  40. service xinetd start
  41. Make this service to start automatically on every reboot:
  42.  
  43. On CentOS 6:
  44.  
  45. chkconfig telnet on
  46. chkconfig xinetd on
  47. On CentOS 7:
  48.  
  49. systemctl start telnet.socket
  50. systemctl enable telnet.socket
  51. Allow the telnet default port 23 through your firewall and Router. To allow the telnet port through firewall, Edit file /etc/sysconfig/iptables on CentOS 6.x systems:
  52.  
  53. vi /etc/sysconfig/iptables
  54. Add the line as shown in red color:
  55.  
  56. # Firewall configuration written by system-config-firewall
  57. # Manual customization of this file is not recommended.
  58. *filter
  59. :INPUT ACCEPT [0:0]
  60. :FORWARD ACCEPT [0:0]
  61. :OUTPUT ACCEPT [0:0]
  62. -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
  63. -A INPUT -p icmp -j ACCEPT
  64. -A INPUT -i lo -j ACCEPT
  65. -A INPUT -p tcp -m state --state NEW --dport 23 -j ACCEPT
  66. -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
  67. -A INPUT -j REJECT --reject-with icmp-host-prohibited
  68. -A FORWARD -j REJECT --reject-with icmp-host-prohibited
  69. COMMIT
  70. Save and exit the file. Restart iptables service:
  71.  
  72. service iptables restart
  73. On CentOS 7, run the following commands to enable telnet service through firewall.
  74.  
  75. firewall-cmd --permanent --add-port=23/tcp
  76. firewall-cmd --reload
  77. Thats it. Now telnet server is ready to use.
  78.  
  79. Creating users
  80. Create a test user, for example “sk” with password “centos“:
  81.  
  82. useradd sk
  83. passwd sk
  84. Client Side Configuration
  85. Install telnet package:
  86.  
  87. yum install telnet
  88. On DEB based systems:
  89.  
  90. sudo apt-get install telnet
  91. Now, open Terminal, and try to access your server(remote host).
  92.  
  93. If your client is Linux system, open the terminal and type the following command to connect to telnet server.
  94.  
  95. telnet 192.168.1.150
  96. Enter username and password which we have created in the server:
  97.  
  98. Sample output:
  99.  
  100. Trying 192.168.1.150...
  101. Connected to 192.168.1.150.
  102. Escape character is '^]'.
  103.  
  104. Kernel 3.10.0-123.13.2.el7.x86_64 on an x86_64
  105. server1 login: sk
  106. Password:
  107. [sk@server1 ~]$
  108. As you see in the above output, the remote system has been successfully accessed from the local machine.
  109.  
  110. If your client is windows system, then go to Start -> Run -> Command Prompt.
  111.  
  112. In the command prompt, type the command:
  113.  
  114. telnet 192.168.1.150
  115. Where 192.168.1.150 is remote host IP address.
  116.  
  117. Now you will be able to connect to your server.
  118.  
  119. That’s it.
  120.  
  121. Cheers!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement