用 Shellinabox 实现 web 端进行 ssh 登陆

大家经常使用的 ssh 工具,基本都是 putty 或 xhell。今天介绍一下另一个 ssh 登陆方法,用 shellinabox 来实现 web 端 ssh 登陆。

shellinabox 的安装

On Debian, Ubuntu and Linux Mint

1
sudo apt-get install shellinabox

On RHEL, CentOS and Fedora

1
yum install openssl shellinabox

设置:

在 debian,ubuntu and Linux Mint 环境下。配置文件 /etc/default/shellinabox

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Should shellinaboxd start automatically
SHELLINABOX_DAEMON_START=1

# TCP port that shellinboxd's webserver listens on
SHELLINABOX_PORT=4200 #这个就是你使用web终端登陆的端口

# Parameters that are managed by the system and usually should not need
# changing:
# SHELLINABOX_DATADIR=/var/lib/shellinabox
# SHELLINABOX_USER=shellinabox
# SHELLINABOX_GROUP=shellinabox

# Any optional arguments (e.g. extra service definitions). Make sure
# that that argument is quoted.
#
# Beeps are disabled because of reports of the VLC plugin crashing
# Firefox on Linux/x86_64.
SHELLINABOX_ARGS="--no-beep"

在 RHEL, CentOS and Fedora 环境下,配置文件在:/etc/sysconfig/shellinaboxd
因为我电脑没有装 centos。下面的代码是我贴来的,不过大至都差不多。

1
2
3
4
5
6
7
8
9
# vi /etc/sysconfig/shellinaboxd
# TCP port that shellinboxd's webserver listens on
PORT=6175 #这个就是你使用web终端登陆的端口

# specify the IP address of a destination SSH server
OPTS="-s /:SSH:172.16.25.125"

# if you want to restrict access to shellinaboxd from localhost only
OPTS="-s /:SSH:172.16.25.125 --localhost-only"

启动服务

Debian, Ubuntu and Linux Mint

1
/etc/init.d/shellinabox start

RHEL and CentOS

1
systemctl shellinaboxd start

检查是否启动

1
2
# netstat -nap | grep shellinabox
tcp 0 0 0.0.0.0:4200 0.0.0.0:* LISTEN 12274/shellinaboxd

使用方法

在任意浏览器中输入 https://你的IP:端口号 , 就可以访问你的 linux 了。