最近需要更改cockpit 服务端口,具体步骤如下:

mkdir -p /etc/systemd/system/cockpit.socket.d/touch /etc/systemd/system/cockpit.socket.d/listen.conf 
vim /etc/systemd/system/cockpit.socket.d/listen.conf

在listen.conf 文件中,输入:

[Socket]
ListenStream=9090ListenStream=7777

重启服务,生效配置:

sudo systemctl daemon-reloadsudo systemctl restart cockpit.socketsudo systemctl restart cockpit.service

防火墙自行配置;

SELinux自行配置;

参考链接:

https://cockpit-project.org/guide/133/listen.html 

更新-2020年6月19日:/usr/lib/systemd/system/cockpit.socket; 文件中也有端口信息,我们需要根据需求进行修改:

[Unit]
Description=Cockpit Web Service Socket
Documentation=man:cockpit-ws(8)
Wants=cockpit-motd.service

[Socket]ListenStream=9000ExecStartPost=-/usr/share/cockpit/motd/update-motd '' localhost
ExecStartPost=-/bin/ln -snf active.motd /run/cockpit/motd
ExecStopPost=-/bin/ln -snf /usr/share/cockpit/motd/inactive.motd /run/cockpit/motd

[Install]
WantedBy=sockets.target