运行 有人 telnet 我的服务器时的脚本
Run script when someone telnet my server
I Have:
1) DigitalOcean 上的 Droplets ubuntu/debian/fedora
2) 简单的脚本回显某些东西 "script.sh"
I want:
当有人从终端远程登录我的服务器时:telnet MY_DROPLET_IP
让我的 script.sh 在他的终端执行然后退出。
总而言之,我需要这样的东西(检查一下):telnet towel.blinkenlights.nl
由于 telnet 不需要握手,您可以 set up xinetd to run the script 连接到端口 23。
安装:
sudo apt-get install xinetd telnetd
/etc/xinetd.d/telnet 文件内容:
service login
{
port = 23
socket_type = stream
protocol = tcp
wait = no
user = root
server = /usr/bin/script.sh
server_args = test
}
/etc/xinetd.conf内容:
{
# Please note that you need a log_type line to be able to use log_on_success
# and log_on_failure. The default is the following :
# log_type = SYSLOG daemon info
instances = 60
log_type = SYSLOG authpriv
log_on_success = HOST PID
log_on_failure = HOST
cps = 25 30
}
includedir /etc/xinetd.d
/etc/inetd.conf内容:
telnet stream tcp nowait telnetd /usr/bin/script.sh
重新启动 xinetd:
/etc/init.d/xinetd restart
编辑:
不要忘记
chmod +x /usr/bin/script.sh
I Have:
1) DigitalOcean 上的 Droplets ubuntu/debian/fedora
2) 简单的脚本回显某些东西 "script.sh"
I want:
当有人从终端远程登录我的服务器时:telnet MY_DROPLET_IP
让我的 script.sh 在他的终端执行然后退出。
总而言之,我需要这样的东西(检查一下):telnet towel.blinkenlights.nl
由于 telnet 不需要握手,您可以 set up xinetd to run the script 连接到端口 23。
安装:
sudo apt-get install xinetd telnetd
/etc/xinetd.d/telnet 文件内容:
service login
{
port = 23
socket_type = stream
protocol = tcp
wait = no
user = root
server = /usr/bin/script.sh
server_args = test
}
/etc/xinetd.conf内容:
{
# Please note that you need a log_type line to be able to use log_on_success
# and log_on_failure. The default is the following :
# log_type = SYSLOG daemon info
instances = 60
log_type = SYSLOG authpriv
log_on_success = HOST PID
log_on_failure = HOST
cps = 25 30
}
includedir /etc/xinetd.d
/etc/inetd.conf内容:
telnet stream tcp nowait telnetd /usr/bin/script.sh
重新启动 xinetd:
/etc/init.d/xinetd restart
编辑: 不要忘记
chmod +x /usr/bin/script.sh