安装并开启 SSH
安装 SSH 并设置开机启动
1
2
3
sudo apt update
sudo systemctl start ssh
sudo systemctl enable ssh
查看当前 IP 地址
1
2
sudo install net-tools
ifconfig
安装 oh-my-bash
1
2
3
sudo apt install curl
sudo apt install git
bash -c " $( curl -fsSL https://raw.githubusercontent.com/ohmybash/oh-my-bash/master/tools/install.sh) "
修改文件 ~/.bashrc
,设置主题为 OSH_THEME="minimal-gh"
。
安装 docker 和 docker-compose
安装 docker
1
2
3
4
5
6
7
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $( lsb_release -cs) stable"
sudo apt install docker-ce docker-ce-cli containerd.io
sudo systemctl start docker
sudo systemctl status docker
sudo systemctl enable docker
sudo usermod -aG docker $USER
安装 docker-compose
1
2
sudo curl -L "https://github.com/docker/compose/releases/download/ $( curl -s https://api.github.com/repos/docker/compose/releases/latest | grep 'tag_name' | cut -d\" -f4) /docker-compose- $( uname -s) - $( uname -m) " -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
修改 /etc/docker/daemon.json
并重启 docker 服务 sudo systemctl restart docker
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{
"registry-mirrors" : [
"https://dockerproxy.com" ,
"https://docker.m.daocloud.io" ,
"https://cr.console.aliyun.com" ,
"https://ccr.ccs.tencentyun.com" ,
"https://hub-mirror.c.163.com" ,
"https://mirror.baidubce.com" ,
"https://docker.nju.edu.cn" ,
"https://docker.mirrors.sjtug.sjtu.edu.cn" ,
"https://github.com/ustclug/mirrorrequest" ,
"https://registry.docker-cn.com"
],
"insecure-registries" : [ "10.177.31.99:8082" ]
}
连接本地仓库
1
docker login 10.177.31.99:8082 -u hackroot
修改 docker /lib/systemd/system/docker.service
,让 portainer 远程连接
1
ExecStart =/ usr / bin / dockerd - H tcp : // 0.0 . 0.0 : 2375 - H unix : /// var / run / docker . sock - H fd : // -- containerd =/ run / containerd / containerd . sock
安装 MooseFS
参考 博客 进行安装。
设置远程桌面
安装远程桌面
安装 ubuntu 桌面和 tigerVNC
1
2
3
sudo apt install ubuntu-desktop -y
sudo apt install tigervnc-standalone-server tigervnc-common -y
sudo apt install dbus-x11
启动后设置密码并关闭
1
2
3
vncserver
vncserver -list
vncserver -kill :1
设置远程桌面启动项 nano ~/.vnc/xstartup
,内容为
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
export XKL_XMODMAP_DISABLE = 1
export XDG_CURRENT_DESKTOP = "GNOME-Flashback:GNOME"
export XDG_MENU_PREFIX = "gnome-flashback-"
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME /.Xresources ] && xrdb $HOME /.Xresources
vncconfig -iconic &
gnome-terminal &
nautilus &
dbus-launch --exit-with-session gnome-session &
将其改为可执行文件 chmod +x ~/.vnc/xstartup
。再执行
1
vncserver -geometry 1920x1080 :1 -localhost no
即可启动 tigerVNC 并远程连接。可能会出现如下错误:
错误 1 :如果连接后一直出现弹窗 Authentication is required to create a color profile/managed device ,则新建文件 sudo nano /etc/polkit-1/localauthority/50-local.d/45-allow-colord.pkla
,内容为
1
2
3
4
5
6
[Allow Colord all Users]
Identity=unix-user:*
Action=org.freedesktop.color-manager.create-device;org.freedesktop.color-manager.create-profile;org.freedesktop.color-manager.delete-device;org.freedesktop.color-manager.delete-profile;org.freedesktop.color-manager.modify-device;org.freedesktop.color-manager.modify-profile
ResultAny=no
ResultInactive=no
ResultActive=yes
错误 2 :如果启动时报错 vncconfig: unable to open display “:1” ,尝试使用
1
sudo vncserver -geometry 1920x1080 :1 -localhost no
设置开机启动
新建 systemd 服务文件
1
sudo nano /etc/systemd/system/vncserver@:1.service
内容为
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[Unit]
Description=Start VNC server at startup
After=syslog.target network.target
[Service]
Type=forking
User=hackroot
Group=hackroot
WorkingDirectory=/home/hackroot
PIDFile=/home/hackroot/.vnc/%H%i.pid
ExecStartPre=-/usr/bin/vncserver -kill :1 > /dev/null 2>&1
ExecStart=/usr/bin/vncserver :1 -geometry 1920x1080 -localhost no
ExecStop=/usr/bin/vncserver -kill :1
[Install]
WantedBy=multi-user.target
设置权限并开机启动
1
2
3
4
sudo chmod 644 /etc/systemd/system/vncserver@:1.service
sudo systemctl daemon-reload
sudo systemctl start vncserver@:1.service
sudo systemctl enable vncserver@:1.service
或者新建脚本并赋予执行权限
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
DISPLAY_NUM = 1
RESOLUTION = "1920x1080"
XSTARTUP = "/usr/bin/gnome-session"
/usr/bin/vncserver -kill :${ DISPLAY_NUM } > /dev/null 2>& 1
rm -rf /tmp/.X${ DISPLAY_NUM } -lock
rm -rf /tmp/.X11-unix/X${ DISPLAY_NUM }
/usr/bin/vncserver :${ DISPLAY_NUM } \
-geometry ${ RESOLUTION } \
-localhost no \
-xstartup ${ XSTARTUP } \
-SecurityTypes VncAuth \
-depth 24
if [ $? -eq 0 ] ; then
echo "✅ Service start at port 590 ${ DISPLAY_NUM } "
echo "🔗 Connect: $( hostname -I | awk '{print $1}' ) : ${ DISPLAY_NUM } "
else
echo "❌ Failed, see log $HOME /.vnc/*.log"
fi
在 /etc/rc.local
中加入 su - hackroot -c "/home/hackroot/vnc_start.sh"
以开机启动。
错误 1 :无法启动,尝试重新安装 gnome
1
2
sudo apt purge gnome-shell --auto-remove
sudo apt install ubuntu-desktop