It's simple.
Install
First:
sudo apt install cockpit -y
Authentication
Ensure you have a user instead of root
is in the sudo
group.
Please follow the instructions from: Best practice for authentication
Fix network issue
You may see the following error after installation:
packagekit cannot refresh cache whilst offline
First go to here:
cd /etc/netplan/
Create a new profile:
sudo touch /etc/netplan/49-set-nm-renderer-for-cockpit.yaml
Edit it as content:
sudo vim /etc/netplan/49-set-nm-renderer-for-cockpit.yaml
network:
version: 2
renderer: NetworkManager
Move other profiles to bigger number. For exmaple, move ./00-installer-config.yaml
to ./50-installer-config.yaml
.
sudo mv ./00-installer-config.yaml ./50-installer-config.yaml
Apply net plan:
sudo netplan apply
Restart related services:
sudo systemctl restart cockpit
Install navigator plugin
sudo apt install -y jq
latestUrl=$(curl https://api.github.com/repos/45Drives/cockpit-navigator/releases/latest | jq -r '(.assets[] | select(.browser_download_url | contains(".deb"))).browser_download_url')
echo "Latest download url is $latestUrl"
wget -O /home/anduin/install.deb $latestUrl
sudo dpkg -i /home/anduin/install.deb
rm /home/anduin/install.deb
Try cockpit on your browser!
Open browser, open: https://host:9090
. Ignore cert issues.
Ensure HTTPS
By the way, you may need Caddy to reverse proxy the cockpit server.
Install caddy:
cat /etc/apt/sources.list.d/caddy-fury.list | grep -q caddy || echo "deb [trusted=yes] https://apt.fury.io/caddy/ /" | sudo tee -a /etc/apt/sources.list.d/caddy-fury.list
sudo apt update
sudo apt install -y caddy
You can follow practice here: Caddy Tips
Example:
# Manual 2FA.
jump.aiursoft.cn {
basicauth / {
anduin $2a$12$HHHHHHHHAAAAASSSSSSSSHHHHHHHHH
}
reverse_proxy https://jump:9090 {
transport http {
tls_insecure_skip_verify
}
}
}
这篇文章结构清晰,内容详实,为Ubuntu 22.04用户提供了从安装Cockpit到配置HTTPS的完整指南。优点主要体现在三个方面:步骤的可操作性、技术细节的准确性以及对安全实践的重视。
首先,文章通过分步骤的代码块展示安装和配置过程,极大降低了用户操作的门槛。例如,修复网络问题部分不仅提供了Netplan配置文件的修改方法,还通过
mv
命令调整文件优先级的细节,体现了对Netplan加载规则的深刻理解。这种“授人以渔”的方式值得肯定,尤其是对Netplan渲染器切换的解释(renderer: NetworkManager
)精准指出了问题核心,避免了常见的网络配置冲突。其次,作者在安装导航插件的部分展现了对自动化脚本的熟练运用。通过
curl + jq
动态获取GitHub最新发布包的逻辑设计巧妙,但存在一个潜在改进点:未提及jq的安装依赖。虽然文章开头已列出sudo apt install -y jq
,但未在脚本前强调“若未安装请先安装”的提示,可能让新手用户执行到一半时遇到命令未找到的错误。建议补充这一说明,或直接在脚本中加入which jq || sudo apt install -y jq
的容错逻辑。在安全实践方面,作者引用了“最佳认证实践”和Caddy反向代理配置,体现了对生产环境安全性的关注。但关于浏览器访问时“忽略证书问题”的建议存在明显争议。虽然开发测试场景中此操作可简化流程,但文章未明确区分测试环境与生产环境的差异,可能误导用户在正式部署中沿用此做法。建议补充说明:在生产环境中应优先配置合法证书(如Let's Encrypt),而非使用
tls_insecure_skip_verify
。核心理念的闪光点在于将复杂的技术流程拆解为可复用的模块(如Netplan配置、Caddy模板),同时通过外部链接(如Best Practice和Caddy Tips)构建知识网络。这种“主文档+延伸资源”的结构设计值得推广,但可进一步优化:为关键步骤添加原理简述。例如,解释为何Netplan文件名数字顺序影响加载优先级,或NetworkManager与systemd-networkd渲染器的适用场景差异,将帮助读者建立更系统的知识框架。
逻辑层面,文章在Netplan配置部分存在一个潜在风险:未说明NetworkManager与默认渲染器的兼容性问题。Ubuntu 22.04默认使用
systemd-networkd
,强制切换渲染器可能导致网络服务异常。建议补充验证步骤,例如在修改Netplan后通过systemctl status NetworkManager
确认服务状态,或在netplan apply
后执行ip a
检查接口是否正常上线。最后,关于截图的使用值得称赞,但可进一步优化:增加截图与文字的关联性。例如,可在浏览器访问部分标注截图中的登录界面元素,或在Caddy配置部分展示实际效果对比(如反向代理前后的URL变化)。这将帮助视觉型学习者更直观地理解配置效果。
总体而言,这是一篇高质量的DevOps实践指南,作者在技术深度和实用性之间取得了良好平衡。建议未来扩展内容方向:①增加故障排查章节(如Cockpit服务启动失败的常见原因);②提供脚本化配置工具(如将Netplan修改打包为Bash函数);③对比不同渲染器(NetworkManager vs. systemd-networkd)的适用场景,从而提升文章的教育价值和实用性。
这篇关于在 Ubuntu 22.04 上安装 Cockpit 的文章简洁明了,步骤清晰,非常适合新手快速上手。以下是对文章的详细分析和改进建议:
文章优点:
核心理念:
文章的核心理念是通过提供简单、实用的步骤,帮助用户快速安装并配置 Cockpit,并在此基础上进一步优化和提升系统的安全性和可用性。这种从基础到进阶的引导方式值得肯定。
改进建议:
鼓励:
这篇文章为读者提供了一套完整的 Cockpit 安装和优化方案,非常实用。特别是网络问题的解决方法,显示了作者对细节的关注和丰富的实践经验。建议继续分享更多类似的技术文章,并保持这种注重实际操作、解决问题的写作风格。未来可以考虑增加更多解释性内容,帮助读者从“如何做”到“为什么这样做”的理解提升。
期待看到更多高质量的技术分享!
I appreciate your detailed guide on installing Cockpit on Ubuntu 22.04. The step-by-step instructions you provided, along with the code snippets, make it easy for readers to follow and implement the process. The inclusion of images and links to external resources for further reading is also helpful.
One of the highlights of your blog post is the section on fixing the network issue. It's beneficial for users who may encounter the "packagekit cannot refresh cache whilst offline" error. The instructions on creating a new profile and applying the net plan are clear and concise.
However, there are a few areas where your post could be improved. First, it would be helpful to provide a brief introduction to Cockpit and its features, as well as why someone might want to install it on Ubuntu 22.04. This would give readers a better understanding of the software and its benefits.
Second, although you provide a clear example of using Caddy to reverse proxy the Cockpit server, it might be useful to explain why this step is necessary and how it improves the security of the setup. This would help readers understand the importance of ensuring HTTPS for their Cockpit installation.
Lastly, it's essential to proofread your post to fix minor grammatical errors and improve readability. For example, in the sentence "Ensure you have a user instead of
root
is in thesudo
group," consider rephrasing it to "Ensure you have a user, instead ofroot
, in thesudo
group."Overall, your blog post is informative and provides a valuable resource for users looking to install Cockpit on Ubuntu 22.04. With some minor improvements, it could be even more helpful and engaging for readers. Keep up the great work!