广告

本站里的文章大部分经过自行整理与测试

2017年1月14日星期六

Linux - SSH 与 Telnet 服务

如果要让外部连接本机 SSH / Telnet 服务,
还要在 firewall 设置打开默认端口
同时, router modem 也要做端口转向 Port Forward

SSH 是一种安全通讯协议, 而 Telnet 不是
Telnet 是以明文传输数据, 所以不安全

SSH (端口 22)

1. 安装

$ su

Ubuntu
$ apt install ssh

Fedora
$ dnf install openssh-clients openssh-server

CentOS
$ yum install openssh-clients openssh-server

OpenSUSE
$ zypper install openssh

以上安装的 ssh / openssh 已包含了客户端与服务端

2. 启动

$ systemctl start sshd

$ netstat -plnt | grep :22

tcp        0      0 0.0.0.0:22          0.0.0.0:*           LISTEN      944/sshd
tcp6      0      0 :::22                   :::*                    LISTEN      944/sshd

3. 连接

$ ssh member@127.0.0.1

member@127.0.0.1's password: 
Welcome to Ubuntu 16.10 (GNU/Linux 4.8.0-34-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

0 packages can be updated.
0 updates are security updates.

Last login: Sat Jan 14 05:10:00 2017 from member.dlinkddns.com

4. 其它

SSH 连接不需要密码
http://jasonmun.blogspot.my/2015/08/ubuntu-ssh-scp.html

SFTP
http://jasonmun.blogspot.my/2017/01/sftp-openssh-server-ftp.html

denyhosts
http://jasonmun.blogspot.my/2017/01/linux-denyhosts.html

Telnet (端口 23)

1. 安装与启动

$ su

Ubuntu
$ apt install telnet telnetd
$ systemctl start inetd

Fedora
$ dnf install telnet telnet-server
$ systemctl start telnet.socket

CentOS
$ yum install telnet telnet-server
$ systemctl start telnet.socket

$ netstat -plnt | grep :23

tcp        0      0 0.0.0.0:23          0.0.0.0:*           LISTEN      803/inetd
tcp6      0      0 :::23                   :::*                    LISTEN      1/systemd

以上安装的 telnet 是客户端, telnetd / telnet-server 是服务端

2. 连接

$ telnet 127.0.0.1

Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
Ubuntu 16.10
member.dlinkddns.com login: member
Password: 
Welcome to Ubuntu 16.10 (GNU/Linux 4.8.0-34-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

0 packages can be updated.
0 updates are security updates.

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

没有评论:

发表评论