如何在 CentOS 8/RHEL 8 上安装和使用 Cockpit
Cockpit
![](/data/attachment/album/201910/12/093405gb8hv3exdbsdyfda.jpg)


Cockpit 是一个基于 Web 的服务器管理工具，可用于 CentOS 和 RHEL 系统。最近发布的 CentOS 8 和 RHEL 8，其中 cockpit 是默认的服务器管理工具。它的软件包在默认的 CentOS 8 和 RHEL 8 仓库中就有。Cockpit 是一个有用的基于 Web 的 GUI 工具，系统管理员可以通过该工具监控和管理 Linux 服务器，它还可用于管理服务器、容器、虚拟机中的网络和存储，以及检查系统和应用的日志。


在本文中，我们将演示如何在 CentOS 8 和 RHEL 8 中安装和设置 Cockpit。


### 在 CentOS 8/RHEL 8 上安装和设置Cockpit


登录你的 CentOS 8/RHEL 8，打开终端并执行以下 `dnf` 命令：



```
[root@linuxtechi ~]# dnf install cockpit -y
```

运行以下命令启用并启动 cockpit 服务：



```
[root@linuxtechi ~]# systemctl start cockpit.socket
[root@linuxtechi ~]# systemctl enable cockpit.socket
```

使用以下命令在系统防火墙中允许 Cockpit 端口：



```
[root@linuxtechi ~]# firewall-cmd --permanent --add-service=cockpit
[root@linuxtechi ~]# firewall-cmd --reload
```

验证 cockpit 服务是否已启动和运行，执行以下命令：



```
[root@linuxtechi ~]# systemctl status cockpit.socket
[root@linuxtechi ~]# ss -tunlp | grep cockpit
[root@linuxtechi ~]# ps auxf|grep cockpit
```

![cockpit-status-centos8-rhel8](/data/attachment/album/201910/12/093431e1qgq904y96xnz55.jpg)


### 在 CentOS 8/RHEL 8 上访问 Cockpit


正如我们在上面命令的输出中看到的，cockpit 正在监听 tcp 9090 端口，打开你的 Web 浏览器并输入 url：`https://<Your-CentOS8/RHEL8-System-IP>:9090`。


![CentOS8-cockpit-login-screen](/data/attachment/album/201910/12/093432n448mj7zb8817x5y.jpg)


RHEL 8 中的 Cockpit 登录页面：


![RHEL8-Cockpit-Login-Screen](/data/attachment/album/201910/12/093433l77b74lq1ba76a6a.jpg)


使用有管理员权限的用户名，或者我们也可以使用 root 用户的密码登录。如果要将管理员权限分配给任何本地用户，请执行以下命令：



```
[root@linuxtechi ~]# usermod -G wheel pkumar
```

这里 `pkumar` 是我的本地用户，


在输入用户密码后，选择 “Reuse my password for privileged tasks”，然后单击 “Log In”，然后我们看到以下页面：


![cockpit-dashboard-centos8](/data/attachment/album/201910/12/093434qznbnpkaavni47kv.jpg)


在左侧栏上，我们可以看到可以通过 cockpit GUI 监控和配置的内容，


假设你要检查 CentOS 8/RHEL 8 中是否有任何可用更新，请单击 “System Updates”：


![Software-Updates-Cockpit-GUI-CentOS8-RHEL8](/data/attachment/album/201910/12/093436x559d52tm4s0ei7b.jpg)


要安装所有更新，点击 “Install All Updates”：


![Install-Software-Updates-CentOS8-RHEL8](/data/attachment/album/201910/12/093437ldid422d4d67fsks.jpg)


如果想要修改网络并要添加 Bond 接口和网桥，请单击 “Networking”：


![Networking-Cockpit-Dashboard-CentOS8-RHEL8](/data/attachment/album/201910/12/093438kp6mcw8777r7y82w.jpg)


如上所见，我们有创建 Bond 接口、网桥和 VLAN 标记接口的选项。


假设我们想创建一个 `br0` 网桥，并要为它添加 `enp0s3` 端口，单击 “Add Bridge”：


将网桥名称指定为 `br0`，将端口指定为 `enp0s3`，然后单击“Apply”。


![Add-Bridge-Cockpit-CentOS8-RHEL8](/data/attachment/album/201910/12/093440y2fec8vllvcs8dre.jpg)


在下个页面，我们将看到该网桥处于活动状态，并且获得了与 enp0s3 接口相同的 IP：


![Bridge-Details-Cockpit-Dashboard-CentOS8-RHEL8](/data/attachment/album/201910/12/093442wigngfcfeqhi00cl.jpg)


如果你想检查系统日志，单击 “Logs”，我们可以根据严重性查看日志：


![System-Logs-Cockpit-Dashboard-CentOS8-RHEL8](/data/attachment/album/201910/12/093443vxm4989d8j3j6r43.jpg)


本文就是这些了，类似地，系统管理员可以使用 cockpit 的其他功能来监控和管理 CentOS 8 和 RHEL 8 服务器。如果这些步骤可以帮助你在 Linux 服务器上设置 cockpit，请在下面的评论栏分享你的反馈和意见。




---


via: <https://www.linuxtechi.com/install-use-cockpit-tool-centos8-rhel8/>


作者：[Pradeep Kumar](https://www.linuxtechi.com/author/pradeep/) 选题：[lujun9972](https://github.com/lujun9972) 译者：[geekpi](https://github.com/geekpi) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
**Cockpit** is a Web based server management tool available for CentOS and RHEL systems, recently **CentOS 8** and **RHEL 8** are released where cockpit is kept as default server management tool. Its package is available in the default CentOS 8 and RHEL 8 package repositories. Cockpit is a useful Web based GUI tool through which sysadmins can monitor and manage their Linux servers, it can also used to manage networking and storage on servers, containers, virtual machines and inspections of system and application’s logs.

In this article we will demonstrate how to install and setup Cockpit on CentOS 8 and RHEL 8 system.

#### Installation and setup of Cockpit on CentOS 8 / RHEL 8 System

Login to your CentOS8 / RHEL 8 system and open the terminal and execute the following dnf command,

[root@linuxtechi ~]# dnf install cockpit -y

Run the following command to enable and start cockpit service,

[root@linuxtechi ~]# systemctl start cockpit.socket [root@linuxtechi ~]# systemctl enable cockpit.socket

Allow Cockpit ports in OS firewall using following command,

[root@linuxtechi ~]# firewall-cmd --permanent --add-service=cockpit [root@linuxtechi ~]# firewall-cmd --reload

Verify whether cockpit service is up and running or not, execute the following commands,

[root@linuxtechi ~]# systemctl status cockpit.socket [root@linuxtechi ~]# ss -tunlp | grep cockpit [root@linuxtechi ~]# ps auxf|grep cockpit

#### Access Cockpit on CentOS 8 / RHEL 8 system

As we can see in above command’s output that cockpit is listening on tcp port 9090, open your system web browser and type url :

https://<Your-CentOS8/RHEL8-System-IP>:9090

Cockpit Login Screen for RHEL 8,

Use the user name which has admin rights, or we can also use the root user’s credentials to login. In case you want to assign admin rights to any local user, execute the following command,

[root@linuxtechi ~]# usermod -G wheel pkumar

here pkumar is my local user,

Once you enter the user’s credentials, choose “**Reuse my password for privileged tasks**” and then click on “**Log In**” option after that we will get following screen,

On the Left-hand side bar, we can see what things can be monitored and configured via cockpit GUI,

Let’s assume if you wish to check whether there are any updates available for your CentOS 8 / RHEL 8 system, click on “**System Updates**” option,

To Install all updates, click on “**Install All Updates**”

If wish to modify networking and want to add Bond interface and Bridge, then click on “**Networking**”

As we can in above window, we have the options to create Bond interface, Bridge and VLAN tagged interface.

Let’s assume we want to create a bridge as “**br0**” and want to add **enp0s3** as port to it, click on “**Add Bridge**” option,

Specify the bridge name as “br0” and port as “enp0s3” and then click on apply

In the next screen we will see that our bridge is active and got the same IP as of enp0s3 interface,

If you wish to inspect system logs then click on “**Logs**” options, there we can view logs based on their severity

That’s all from this article, similarly sysadmins can use remaining other options of cockpit to monitor and manage their CentOS 8 and RHEL 8 server. In case these steps help you to setup cockpit on your Linux server then please do share your feedback and comments in the comments section below.

**Read Also** : [How to Install and Configure VNC Server on Centos 8 / RHEL 8](https://www.linuxtechi.com/install-configure-vnc-server-centos8-rhel8/)

**Read Also** : [How to Install Cockpit Web Console on Ubuntu 20.04 Server](https://www.linuxtechi.com/how-to-install-cockpit-on-ubuntu-20-04/)

sivaIf we want add the cluster for this . Please share the steps

jayI just want to know how to use cockpit with reverse proxy like traefik

Pradeep KumarFirst You need deploy cockpit in a container and then deploy traefik container inside your Docker setup after that traefik will automatically discover cockpit. To access the Cockpit GUI, You will use traefik IP and Cockpit container port.

MartinNice, but why not just use DNF automatic and (optional) let it report by e-mail about (auto-installed) updates.