
windows客戶端如果通過cmd窗口連接到遠程linux服務器,可以使用telnet;
centos系統默認telnet 23端口是關閉的。
服務器本地使用nmap ip地址 -p 23 查看telnet狀態是關閉的;
nmap - Network exploration tool and security / port scanner
[root@localhost ~]# nmap 192.168.20.3 -p 23
Starting Nmap 5.51 ( http://nmap.org ) at 2016-03-11 09:04 CST
Nmap scan report for 192.168.20.3
Host is up (0.00014s latency).
PORT STATE SERVICE
23/tcp closed telnet
打開telnet端口的步驟如下:
1、服務器安裝telnet包(telnet-server包依賴xinetd包)
1
|
# yum install telnet telnet-server -y
|
2、修改telnet配置文件
1
|
# vi /etc/xinetd.d/telnet
|
修改disable=yes 改為no
service telnet
{
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/sbin/in.telnetd
log_on_failure += USERID
disable = no
}
保存退出,重啟xinted服務
1
2
3
|
[root@localhost ~]
# /etc/init.d/xinetd restart
Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]
|
再次掃描發現狀態變為open
[root@localhost ~]# nmap 192.168.20.3 -p 23
Starting Nmap 5.51 ( http://nmap.org ) at 2016-03-11 10:08 CST
Nmap scan report for 192.168.20.3
Host is up (0.00051s latency).
PORT STATE SERVICE
23/tcp open telnet
查看監聽的端口23也有了
[root@localhost ~]# netstat -nlt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
tcp 0 0 :::22 :::* LISTEN
tcp 0 0 :::23 :::* LISTEN
tcp 0 0 ::1:25 :::* LISTEN
3、iptables添加規則允許23端口通過,保存規則,並重啟iptables服務
1
2
3
|
# iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 23 -j ACCEPT
# /etc/init.d/iptables save
# /etc/init.d/iptables restart
|
4、windows本地打開cmd窗口
輸入命令:telnet ip地址 連接到遠程linux服務器
默認情況下telnet連接后不能使用超級用戶,如果要使用超級用戶root登錄,有2種方法可以實現:
第一種:# mv /etc/securetty /etc/securetty.bak 這樣就可以使用root登錄,非常不建議這樣操作!!!!
第二種:# vi /etc/securetty
添加
pts/0
pts/ 1
pts/2
pts/3
如果登錄的用戶比較多,可以添加更多的pts/**
這樣添加的作用,是允許root從pts/0到pts/3這幾個終端登錄;
相比網上其他的方法徹底移除認證的方法,此方法沒有破壞linux安全驗證機制,較為安全!
建議使用普通用戶登錄,su - root 進行切換,為了安全起見,不直接使用root登錄;
如果非要使用root登錄,建議使用SSH工具;
1
2
3
4
5
6
7
8
9
10
|
CentOS release 6.5 (Final)
Kernel 2.6.32-431.el6.i686 on an i686
login: user1
Password:
Last login: Fri Mar 11 11:35:11 from 192.168.20.1
[user1@localhost ~]$
id
uid=500(user1) gid=502(user1)
groups
=502(user1) context=unconfined_u:unconfined_
r:unconfined_t:s0-s0:c0.c1023
[user1@localhost ~]$
whoami
user1
|