安装并配置shellinabox(基于Web的SSH终端模拟器)

写在前面:

今天出了门,带着我的小电脑,到目的地后准备写一些python代码,打开电脑发现它自检不通过,我知道问题应该是内存条没装好导致,但手里没有螺丝刀,正好旁边有公用的电脑,另外我想到之前我在UCLOUD上买过一台云主机,于是想要通过这台公用电脑的浏览器写代码,这就是这篇随笔诞生的一个原因。另一个原因是我先尝试了gateone后又放弃了它,这才有了这篇文章。

大家有兴趣也可以看看《安装并配置gateone(基于Web的SSH终端模拟器)》

1.安装epel源

yum -y install epel-release

2.安装shellinabox

yum -y install shellinabox

3.修改侦听端口

sed -i "s/PORT=4200/PORT=5656/g" /etc/default/shellinaboxd

4.防火墙放行5656端口

firewall-cmd --permanent --zone=public --add-port=5656/tcp

firewall-cmd --reload

5.创建一个普通用户

useradd -d "/home/pythonops" -s "/bin/bash" pythonops

passwd pythonops

6.给普通用户授予sudo权限

chmod +w /etc/sudoers

sed -i '100a  pythonops ALL=(ALL)  ALL'  /etc/sudoers

chmod -w /etc/sudoers

7.自签x509格式的SSL证书

mkdir /root/ssl/

cd /root/ssl/

openssl req -new -x509 -nodes -out server.crt -keyout server.key

8.将证书配置到shellinabox中

如果要域名访问,则保存的格式应该是 certificate-域名.pem,IP 访问则是 certificate.pem

因为我没有域名,所以使用IP访问。

cat server.crt server.key > /var/lib/shellinabox/certificate.pem

9.启动服务

systemctl enable shellinaboxd

systemctl start shellinaboxd

systemctl status shellinaboxd

10.访问

https://yourip:5656

提醒:

shellinabox默认不可以使用root登陆,必须使用普通用户登陆上后,再使用su切换到root。这是一个很不错的安全限制。

使用过后的感想:

不适合用于python开发,不支持中文输入,无法将来自其它地方的大段的内容按原格式复制进去,也无法将来自shellinabox中的内容复制到浏览器的其它的窗口,最糟糕的是,运行的python程序无法通过input函数输入内容。

https://vircloud.net/linux/web-shell.html#selection-295.2-295.6

人生短,迷茫路一程又一程。 脚步重,雨雪天踟蹰也踟蹰。 滴水聚,久无成效伊人不见。 该如何,敲击敲击昼夜不停。
原文地址:https://www.cnblogs.com/DesignerA/p/11625003.html