我正在尝试设置一个类似经典 ASCII 星球大战项目的 ASCII Art Telnet 服务器:
telnet towel.blinkenlights.nl
https://github.com/nitram509/ascii-telnet-server
我已经成功设置了 telnet 服务器,但我缺少最后一步,即让 asciiplayer 在 telnet 接入时运行。(理想情况下,我希望它像 Towel.blinkenlights.nl 那样工作,您无需登录,ASCII 影片就会立即启动。)
设置 TELNET
这是我在设置防火墙并打开端口 23 后使用运行 Ubuntu 16.04.2 x64 的新 Digital Ocean droplet 所遵循的步骤。
安装 telnetd 和 xinetd:sudo apt-get install xinetd telnetd
在 /etc/xinetd.d 中创建 telnet 文件:sudo nano /etc/xinetd.d/telnet
# default: on
# description: The telnet server serves telnet sessions; it uses
# unencrypted username/password pairs for authentication.
service telnet
{
disable = no
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/sbin/in.telnetd
log_on_failure += USERID
}
重新启动 xinetd 服务:sudo service xinetd restart
让 ASCIIPLAYER 工作
我已经确认这允许 telnet 访问(使用用户名/密码)
我将 asciiplayer 文件夹上传到/opt/
根据 asciiplayer 的 README,我需要将上述配置替换为/etc/xinetd.d/telnet
以下内容:
# default: on
# description: An telnet service playing an ASCII movie
service telnet
{
disable = no
socket_type = stream
protocol = tcp
port = 23
user = root
wait = no
instances = 10
log_type = FILE /var/log/asciiplayer
log_on_success += PID HOST DURATION
log_on_failure = HOST
server = /usr/bin/python
server_args = -u -OO /opt/asciiplayer/ascii_telnet_server.py -f /opt/asciiplayer/sw1.txt --stdout
}
执行此操作后,我无法再远程登录服务器。它只是返回:
telnet:无法连接到远程主机:连接被拒绝
我遗漏了流程的哪一部分?我觉得非常接近了。我已经执行了上述流程几次,但就是无法让 ascii_telnet_server.py 在 telnet 时运行。世界需要更多通过 telnet 播放的 ASCII 电影!!任何帮助都将不胜感激...
答案1
感谢@dirkt 的评论/提示/帮助,我能够找到简单的解决方案。
直接以 root身份运行/opt/asciiplayer/ascii_telnet_server.py -f /opt/asciiplayer/sw1.txt --stdout
返回以下错误:
/opt/asciiplayer/ascii_telnet_server.py: line 43:
: No such file or directory
from: can't read /var/mail/__future__
/opt/asciiplayer/ascii_telnet_server.py: line 46: import: command not found
/opt/asciiplayer/ascii_telnet_server.py: line 47: import: command not found
from: can't read /var/mail/optparse
from: can't read /var/mail/ascii_telnet.ascii_movie
from: can't read /var/mail/ascii_telnet.ascii_player
from: can't read /var/mail/ascii_telnet.ascii_server
/opt/asciiplayer/ascii_telnet_server.py: line 55: syntax error near unexpected token `('
/opt/asciiplayer/ascii_telnet_server.py: line 55: `def runTcpServer(interface, port, filename):'
看起来这个问题是一个简单的 Python 路径问题...所以,我用(这是给我的路径)# !/usr/bin/env python
替换了opt/asciiplayer/ascii_telnet_server.py
# !/usr/bin/python
which python
为了您的 ASCII 乐趣,请尝试:(telnet 138.197.212.250
由于我继续开发,IP 可能会发生变化)