Linux Command telnet-Telnet-based remote Logon

Source: Internet
Author: User
Tags close close nameserver telnet program to domain
Document directory
  • Example 1 remote server access failure
  • Example 2: The domain name cannot be resolved
  • Example 3 if the telnet service is not enabled for the target host
  • Example 4 how to start the telnet service? (The telnet service is not recommended. Use a safer SSH service)
  • Example 5 normal Telnet
  • Example 6 use Telnet to test the Web Server
  • Example 7 enter the Telnet command mode
Description

Telnet commands are usually used for remote logon. The telnet program is a remote client logon program based on the Telnet protocol, and the latest Telnet protocol version is rfc854. The telnet protocol is a member of the TCP/IP protocol family and is the standard protocol and main method of the Internet remote login service. It provides users with the ability to complete remote host work on local computers. Use the telnet program on the terminal user's computer to connect to the server. End users can enter commands in the telnet program. These commands will run on the server, just as they are directly entered on the server console. You can control the server locally. To start a telnet session, you must enter the user name and password to log on to the server. Telnet is a common method to remotely control web servers.

However, Because telnet uses plain text to send packets, the security is poor. Many Linux servers do not enable the telnet service, but use a safer SSH mode. However, many other systems may use Telnet to provide remote logon. Therefore, it is necessary to find out how to use the Telnet client.
Telnet commands can also be used for other purposes, such as determining the status of remote services, such as determining whether a port of the remote server can be accessed.

Common Parameters

Format: Telnet hostname

Remotely log on to the machine specified by hostname. The default port is 23.

 

Format: Telnet hostname Port

Remotely log on to the machine specified by hostname and use the port.

 

You can use Ctrl +] to enter the command mode after the connection is successful.

Help help

Q: exit and close the telnet connection.

 

Example 1: remote server access failure

[Root @ new55 ~] # Telnet 192.168.6.6
Trying 192.168.6.6...
TELNET: connect to address 192.168.6.6: No route to host
TELNET: Unable to connect to remote host: No route to host
[Root @ new55 ~] #

How to handle this situation:

(1) Are you sure the IP address is correct?

(2) Are you sure the host corresponding to the IP address is on?

(3) If the host has been started, are you sure the route settings are correct? (Use the route command to view details)

(4) If the host has been started, are you sure you have enabled the telnet service on the host? (Run the netstat command to check whether the TCP port 23 has the listen status line)

(5) If the telnet service has been enabled on the host, are you sure the firewall has opened port 23? (Use iptables-Save to view details)

 

Example 2: The domain name cannot be resolved

[Root @ new55 ~] # Telnet www.11111.com
Www.11111.com/telnet: name or service not known
[Root @ new55 ~] #

How to handle this situation:

(1) Are you sure the domain name is correct?

(2) are the settings related to domain name resolution on the local machine correct? (Whether the nameserver settings in/etc/resolv. conf are correct. If not, you can use nameserver 8.8.8.8.8)

(3) Are you sure you have opened the access to the udp53 port in the firewall? (DNS uses UDP protocol, port 53, and iptables-save for viewing)

 

Example 3 if the telnet service is not enabled for the target host

[Root @ new55 ~] # Telnet www.163.com
Trying 58.242.249.26...
TELNET: connect to address 58.242.249.26: Connection refused
TELNET: Unable to connect to remote host: Connection refused
[Root @ new55 ~] #

How to handle this situation:

(1) Are you sure the IP address or host name is correct?

(2) check whether the port is correct. Is the default port 23?

 

Example 4 how to start the telnet service? (The telnet service is not recommended. Use a safer SSH service)

To start the telnet service, follow these steps:

(1) Open the Telnet file under/etc/xinetd. D, change disable = yes to disable = No, and save.

(2) restart the xinetd service: Service xinetd restart

This allows remote access from non-root users. Note: the root account is not allowed to log on.

 

Example 5 normal Telnet

Generally, root users are not allowed to log on remotely. you can log on with a common account and then use Su-to switch to the root user.

[Root @ new55 ~] # Telnet 192.168.6.115
Trying 192.168.6.115...
Connected to 192.168.6.115 (192.168.6.115 ).
Escape Character is '^]'.
Red Hat Linux release 7.3 (Valhalla)
Kernel 2.4.18-3 on an i686
Login: Root
Password:
Login incorrect

Login: Root
Password:
Login incorrect

Login: Web
Password:
[Web @ localhost web] $
[Web @ localhost web] $

[Web @ localhost web] $ su-
Password:
[Root @ localhost root] #
[Root @ localhost root] #
[Root @ localhost root] #
[Root @ localhost root] # exit
Logout

[Web @ localhost web] $

[Web @ localhost web] $
[Web @ localhost web] $ exit
Logout

Connection closed by foreign host.
[Root @ new55 ~] #

 

Example 6 use Telnet to test the Web Server

[Root @ new55 ~] # Telnet www.163.com 80
Trying 58.242.249.26...
Connected to www.163.com (58.242.249.26 ).
Escape Character is '^]'.
Get, HTTP, 1.0

HTTP/1.0 403 Forbidden
Server: CDN Cache Server V2.0
Date: Tue, 07 Dec 2010 04:46:12 GMT
Content-Type: text/html
Content-Length: 1156
Expires: Tue, 07 Dec 2010 04:46:12 GMT
X-via: 1.0 hf44: 8104 (CDN Cache Server V2.0)
Connection: Close

<! Doctype HTML public "-// W3C // dtd html 4.01 transitional // en" "http://www.w3.org/TR/html4/loose.dtd">
<HTML> <Meta HTTP-EQUIV = "Content-Type" content = "text/html; charset = gb2312">
<Title> error: the requested URL cannot be obtained </title>
<Style type = "text/CSS"> <! -- Body {background-color: # ffffff; font-family: verdana, sans-serif} Pre {font-family: sans-serif} --> </style>
</Head> <body>
<H1> error <H2> the requested URL cannot be obtained </H2>
<HR noshade size = "1px">
<P>
When you try to read the following URL:
<A href = "http: // 58.242.249.44/"> http: // 58.242.249.44/</a>
<P>
The following error occurs:
<Ul>
<Li>
<Strong>
Access denied.
<Br> Access Denied
</Strong>
<P>
Access Control Configuration prevents your request from
Being allowed at this time. Please contact your service provider if
You feel this is incorrect.
<Br>
The current access control settings prohibit your request from being accepted,
If you think this is incorrect, contact your network service provider.
</Ul>
</P>
<P> Cache Server administrator: <a href = "mailto: cdnsupport@chinanetcenter.com"> cdnsupport@chinanetcenter.com </a>

<Br clear = "all">
<HR noshade size = "1px">
<Address>
Generated Tue, 07 Dec 2010 04:46:12 GMT by cache.51cdn.com (CDN Cache Server V2.0)
</Address>
</Body> Connection closed by foreign host.
[Root @ new55 ~] # Telnet www.163.com 80
Trying 58.242.249.26...
Connected to www.163.com (58.242.249.26 ).
Escape Character is '^]'.
Get, HTTP, 1.0

HOST: www.163.com

 

The response header and homepage HTML text are output here, which is omitted.

[Root @ new55 ~] #

 

Example 7 enter the Telnet command mode

[Root @ new55 ~] # Telnet 192.168.6.115
Trying 192.168.6.115...
Connected to 192.168.6.115 (192.168.6.115 ).
Escape Character is '^]'.
Red Hat Linux release 7.3 (Valhalla)
Kernel 2.4.18-3 on an i686
Login: Web
Password:
Last login: Tue Oct 19 21:53:15 from 192.168.6.55
[Web @ localhost web] $
[Web @ localhost web] $
[Web @ localhost web] $
[Web @ localhost web] $ Ctrl +]
Telnet> help
Commands may be abbreviated. commands are:

Close close current connection
Logout forcibly logout remote user and close the connection
Display display Operating Parameters
Mode try to enter line or character mode ('mode? 'For more)
Open connect to a site
Quit exit Telnet
Send transmit special characters ('send? 'For more)
Set set operating parameters ('set? 'For more)
Unset operating parameters ('unset? 'For more)
Status print status information
Toggle toggle operating parameters ('toggle? 'For more)
SLC change state of special charaters ('slc? 'For more)
Auth turn on (off) authentication ('auth? 'For more)
Encrypt turn on (off) encryption ('encrypt? 'For more)
Forward turn on (off) credential Forwarding ('forward? 'For more)
Z suspend Telnet
! Invoke a subshell
Environ change environment variables ('environ? 'For more)
? Print help information
Telnet> display
Will flush output when sending interrupt characters.
Won't send interrupt characters in urgent mode.
Won't send login name and/or authentication information.
Won't skip reading ~ /. Telnetrc file.
Won't map carriage return on output.
Will recognize certain control characters.
Won't turn on socket level debugging.
Won't print hexadecimal representation of network traffic.
Won't print user readable output for "netdata ".
Won't show option processing.
Won't print hexadecimal representation of terminal traffic.

Echo [^ e]
Escape [^]
Rlogin [off]
Tracefile "(standard output )"
Flushoutput [^ o]
Interrupt [^ C]
Quit [^ \]
EOF [^ d]
Erase [^?]
Kill [^ u]
Lnext [^ V]
Susp [^ Z]
Reprint [^ r]
Worderase [^ w]
Start [^ q]
Stop [^ s]
Forw1 [off]
Forw2 [off]
Ayt [^ t]
Do echo
Resp will_wont ECHO: 1
Want wont echo
Do suppress go ahead
Do status
Will terminal type
Will naws
Will tspeed
Will lflow
Resp will_wont xdisploc: 1
Want wont xdisploc
Will new-environ

[Web @ localhost web] $
[Web @ localhost web] $
[Web @ localhost web] $ Ctrl +]
Telnet> q
Connection closed.
[Root @ new55 ~] #

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.