原创 如何在Fedora22下使用telnet

2016-5-20 14:41 1069 21 21 分类: MCU/ 嵌入式 文集: Qt和Cpp
在使用telnet之前,先回顾一下SSH和FTP:
SSH是SecureShell协议,FTP是FileTransfer协议。

--------------------------------
如何在Fedora22下使用SSH?
1. 准备两台安装有Fedora22的主机A和B;
2. 安装openssh:
# dnf install openssh-server
# dnf install openssh

********
Tips: 有关systemd
早期的红帽系,其Linux服务是通过很多启动脚本来管理的,这种方式也称为SysV。它非常容易使用,并且便于扩展。service命令用来启动一个System V init脚本,这些脚本存放在/etc/init.d下。

如果我们在此目录下增加一个可执行脚本:
# touch /etc/init.d/maria
# chmod +x maria
那么运行service命令时,就会发现它可被启动:
$ service m
maria       mcelog      mdmonitor   multipathd

systemd是Linux的系统与服务管理器,它替代了SysV的大部分功能。
如果我们要启动systemd的服务,就使用systemctl命令。
ps:实际上当使用了systemctl命令之后,service命令也会相应的生成。
********

3. 启动服务:
# systemctl start sshd.service
# systemctl status sshd.service
● sshd.service - OpenSSH server daemon
   Loaded: loaded (/usr/lib/systemd/system/sshd.service; disabled; vendor preset: disabled)
   Active: active (running) since Fri 2016-05-20 12:38:44 CST; 40min ago

4. 观察服务是否启动:
# netstat -lpnut
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 192.168.122.1:53        0.0.0.0:*               LISTEN      1484/dnsmasq
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      22959/sshd
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      2200/cupsd
tcp6       0      0 :::22                   :::*                    LISTEN      22959/sshd
tcp6       0      0 ::1:631                 :::*                    LISTEN      2200/cupsd

5. 使用A主机连接B主机:
$ ssh maria@192.168.1.107
The authenticity of host '192.168.1.107 (192.168.1.107)' can't be established.
ECDSA key fingerprint is SHA256:08Rq2SKHf2CvZBn6sjLzSeJczoSlDXbhaac46Id59QQ.
ECDSA key fingerprint is MD5:c2:cd:49:7e:56:43:15:30:b8:fa:69:a5:9b:ad:bd:38.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.107' (ECDSA) to the list of known hosts.
maria@192.168.1.107's password:
Last login: Fri May 20 05:26:54 2016
[maria@localhost ~]$

--------------------------------
如何在Fedora22下使用FTP?
1. 安装ftp:
# dnf install vsftpd
# dnf install ftp

2. 启动ftp服务:
# systemctl start vsftpd.service
# systemctl status vsftpd.service
● vsftpd.service - Vsftpd ftp daemon
   Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; disabled; vendor preset: disabled)
   Active: active (running) since Fri 2016-05-20 13:34:56 CST; 5s ago

3. 观察服务是否启动:
# netstat -lpnut
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 192.168.122.1:53        0.0.0.0:*               LISTEN      1484/dnsmasq
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      22959/sshd
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      2200/cupsd
tcp6       0      0 :::21                   :::*                    LISTEN      26875/vsftpd

4. 安装Firewall(iptables的图形版),在图形界面中打开ftp服务:
# dnf install firewall-config
# firewall-config

5. 使用A主机连接B主机:
$ ftp 192.168.1.107
Connected to 192.168.1.107 (192.168.1.107).
220 (vsFTPd 3.0.2)
Name (192.168.1.107:maria): maria
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>

--------------------------------
Telnet是传输控制协议/因特网协议(TCP/IP)网络(例如Internet)的登录和仿真程序。它最初是由ARPANET开发的,但是现在它主要用于Internet会话。它的基本功能是,允许用户登录进入远程主机系统。

如何在Fedora22下使用telnet?

1. 安装telnet和telnet-server
# dnf install telnet
# dnf install telnet-server

2. 打开telnet服务:
# systemctl start telnet.socket
# systemctl status telnet.socket
● telnet.socket - Telnet Server Activation Socket
   Loaded: loaded (/usr/lib/systemd/system/telnet.socket; disabled; vendor preset: disabled)
   Active: active (listening) since Fri 2016-05-20 14:28:58 CST; 25s ago

3. 安装Firewall(iptables的图形版),在图形界面中打开ftp服务:
# dnf install firewall-config
# firewall-config

4. 使用A主机登陆B主机:
$ telnet 192.168.1.107
Trying 192.168.1.107...
Connected to 192.168.1.107.
Escape character is '^]'.
Fedora release 22 (Twenty Two)
Kernel 4.0.4-301.fc22.x86_64 on an x86_64 (3)
localhost login: maria
Password:
Last login: Fri May 20 13:22:31 from 192.168.1.104
[maria@localhost ~]$ ls
Desktop  Documents  Downloads  Music  Pictures  Public  Templates  Videos
[maria@localhost ~]$  

telnet的用法和ssh差不多啦~
现在可以使用telnet来远程操作主机了。

文章评论0条评论)

登录后参与讨论
我要评论
0
21
关闭 站长推荐上一条 /2 下一条