Oracle Cloud 甲骨文云基本配置知识
在 Oracle Cloud 上配置 Linux 实例时,通常需要完成 root 登录、依赖安装和防火墙规则整理等基础步骤。
下面按场景整理常用的初始配置步骤。
步骤 1:启用 root 登录
获取管理员权限:
sudo -i设置 root 密码:
sudo passwd root允许 root 通过 SSH 登录:
sudo sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config启用密码认证:
sudo sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g' /etc/ssh/sshd_config重启 SSH 服务:
sudo service sshd restart步骤 2:安装基础依赖
CentOS
yum update -y
yum install curl -yUbuntu
apt update -y
apt-get install curl -y步骤 3:清理组件与防火墙规则
CentOS
删除多余 Oracle Cloud Agent:
systemctl stop oracle-cloud-agent
systemctl disable oracle-cloud-agent
systemctl stop oracle-cloud-agent-updater
systemctl disable oracle-cloud-agent-updater停止并禁用 firewalld:
systemctl stop firewalld.service
systemctl disable firewalld.service关闭 SELinux(手动修改):
vi /etc/selinux/config
# 将 SELINUX=ENFORCING 修改为 SELINUX=DISABLED重启系统:
rebootUbuntu
开放端口并清空规则:
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
iptables -F删除默认 Iptables 持久化规则:
apt-get purge netfilter-persistent必要时强制删除:
rm -rf /etc/iptables重启系统:
reboot注意事项
执行前请确认每条命令的影响范围,尤其是防火墙与 SSH 配置相关操作,避免远程连接中断或产生不必要的安全暴露。