如果 sshd 没有响应,如何连接到 OCI 机器?

How to connect to OCI machine if the sshd is not responding?

我正在更新 Oracle 云基础设施机器的 ssh 端口

我改了/etc/ssh/sshd_config 端口是

#Port 22

我改成了

Port 40531

然后

  1. 重新启动了 sshd 服务 systemctl restart sshd
  2. 在OCI Web上打开端口

但是,现在我无法连接。

ssh -vvv -p 40531 -i ~/.ssh/vm.key opc@129.xxx.xxx.xxx
OpenSSH_8.2p1, OpenSSL 1.1.1e  17 Mar 2020
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: resolve_canonicalize: hostname 129.xxx.xxx.xxx is address
debug2: ssh_connect_direct
debug1: Connecting to 129.xxx.xxx.xxx [129.xxx.xxx.xxx] port 40531.
debug1: connect to address 129.xxx.xxx.xxx port 40531: Connection timed out
ssh: connect to host 129.xxx.xxx.xxx port 40531: Connection timed out

我看到一个Cloud Shell但我不确定它是否可以用来连接到机器来执行维护任务

有没有办法从 web oci 界面连接到 VM 以修复 ssh 问题?

我曾经使用 VPS 服务,该服务有一个 Web 控制台,您可以从该控制台进入以解决此类问题

OCI里有这样的东西吗?

:

上述更改效果很好,唯一导致我这边出现问题的是 (我真的不知道为什么)是我是从 VPN 连接的

在我断开 VPN 连接并尝试再次连接后它成功了

更新:

我弄明白了为什么使用不同端口的 ssh 无法正常工作。我使用的 VPN 是企业 VPN,它具有非常严格的入站和出站规则,VPN 出站规则被端口 40xxx 上的 TCP 阻止。

更新:

如果您在使用 VM 时遇到困难,可以使用以下说明进行连接

创建实例控制台连接 在连接到串行控制台或 VNC 控制台之前,您需要创建实例控制台连接。

To create the console connection for an instance
Open the navigation menu. Under Core Infrastructure, go to Compute and click Instances.
Click the instance that you're interested in.
Under Resources, click Console Connection.

Click Create Console Connection.
Upload the public key (.pub) portion for the SSH key. You can browse to a public key file on your computer or paste your public key into the text box.
Click Create Console Connection.

When the console connection has been created and is available, the state changes to Active.

感谢@bmuthuv info

您可以连接到 VM 的串行控制台,在那里您可以在重新启动操作期间访问 GRUB 菜单。您随后可以使用典型的 Linux 命令从 Grub 获取 Shell。您随后可以撤消任何您想要的操作。

可以在实例页面的 OCI Web 控制台上创建串行控制台连接。