Jim's Blog
Toggle navigation
Jim's Blog
Home
About Me
Archives
Tags
绿联 DX4600 开启 ssh
2022-11-28 02:37:00
1823
0
0
jim
## 1. 使用 Charles 获取 API Token 随便用客户端创建个 Docker 容器,查看 Token: ``` 'http://192.168.3.125:9999/containers/create?name=hack&ugreen_nas_model=docker&api_token=xxxxGJkMTIyMzM0Y2YxYTBlZTJmZGI2MDhlODE0YjM4YzhiODhkYg%3D%3D' ``` Token 示例: ``` xxxxGJkMTIyMzM0Y2YxYTBlZTJmZGI2MDhlODE0YjM4YzhiODhkYg%3D%3D ``` ## 2. 创建 Hack 容器 ### 创建容器配置 container.json container.json 文件内容如下: ``` { "_query": { "name": "hack" }, "name": "hack", "AttachStdout": false, "AttachStderr": false, "ExposedPorts": {}, "Tty": true, "OpenStdin": true, "Env": [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" ], "Cmd": [ "/bin/sh" ], "Healthcheck": {}, "Image": "alpine:latest", "Volumes": null, "Entrypoint": null, "OnBuild": null, "Labels": null, "HostConfig": { "PidMode": "host", "Privileged": true, "Devices": [ { "CgroupPermissions": "mrw", "PathInContainer": "/dev/dri/renderD128", "PathOnHost": "/dev/dri/renderD128" }, { "CgroupPermissions": "mrw", "PathInContainer": "/dev/dri/card0", "PathOnHost": "/dev/dri/card0" } ], "NetworkMode": "host", "PortBindings": {}, "RestartPolicy": { "Name": "always" }, "LogConfig": {}, "Sysctls": {}, "Mounts": [ { "Target": "/host", "Source": "/", "ReadOnly": false, "Type": "bind", "Consistency": "default", "Mode": "RW" } ], "Links": [] }, "NetworkingConfig": { "EndpointsConfig": {} } } ``` ### 创建容器 自行替换 `api_token` 内容 ```shell #!/bin/bash curl --compressed \ -H 'Host: 192.168.3.125:9999' \ -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) UGREEN_Nas/3.9.0 Chrome/91.0.4472.164 Electron/13.3.0 Safari/537.36' \ -H 'Content-Type: application/json' \ -H 'Accept: */*' \ -H 'Referer: http://192.168.3.125:9999/service/web/' \ -H 'Accept-Language: en-US' \ --data-binary @container.json \ 'http://192.168.3.125:9999/containers/create?name=hack&ugreen_nas_model=docker&api_token=xxxxxJkMTIyMzM0Y2YxYTBlZTJmZGI2MDhlODE0YjM4YzhiODhkYg%3D%3D' ``` ### 绿联应用上登录容器终端 * 进入绿联系统 ```shell nsenter -t 1 -m /bin/sh ``` * 进入系统后创建 ssh 登录(记得添加自己的公钥到 /root/.ssh/authorized_keys) ```shell ssh-keygen -A chmod go-w /root chmod 700 /root/.ssh chmod 600 /root/.ssh/authorized_keys cat > /etc/init.d/sshd <<EOF #!/bin/sh /etc/rc.common # Copyright (C) 2022-2022 Jim Ma START=99 STOP=10 USE_PROCD=1 PROG=/usr/sbin/sshd mkdir -p /var/empty start_service() { procd_open_instance procd_set_param command "$PROG" -D procd_close_instance } EOF chmod +x /etc/init.d/sshd service sshd enable ``` ### 登录 ssh 默认的端口是 922,如果不是请自行查找 ```shell ssh -p 922 root@192.168.3.125 ``` ## 忽略这里,绿联的系统不支持 tun/tap,无法创建虚拟机 ``` VM_IMAGE_FILE=/mnt/dm-0/ubuntu-22.04-server-cloudimg-amd64.img docker run --rm -it \ --device=/dev/kvm:/dev/kvm --device=/dev/net/tun:/dev/net/tun \ --cap-add NET_ADMIN -v $VM_IMAGE_FILE:/image \ --entrypoint=/bin/bash \ jkz0/qemu:latest ```
Pre:
硬酷 R1 LACP 万兆 iperf3 简单测试
Next:
Registry Authentication
0
likes
1823
新浪微博
微信
腾讯微博
QQ空间
人人网
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus
Table of content