由于可能遭到黑客攻击,无法通过 ssh 从运行 centos6 的 gcloud 实例下载数据以获取 moodle 备份

由于可能遭到黑客攻击,无法通过 ssh 从运行 centos6 的 gcloud 实例下载数据以获取 moodle 备份

我在 gcloud vm 实例中有一个 centos 6 lamp moodle 服务器,2 天前用户报告访问 moodle 时出现数据库连接错误。

通过我的研究,我发现了以下事实:

  1. 重新启动实例不起作用,它实际上导致了 apache 出现问题,因为我甚至无法从服务器提供 html 页面,即使 httpd 服务已启动并重新启动。

  2. 检查了 apache 和安全日志,日志似乎表明有黑客攻击的企图,这是我的错,也可能是发生这种情况的原因。

我想我会尝试获取我的数据并在新的实例上重新开始,但是当我尝试 ssh 进入服务器(ssh web 或 gcloud ssh cli 或 filezilla)下载通过我设置的脚本自动创建的备份 zip 文件时,我似乎根本无法 ssh 以下是一些详细信息:

  • 在浏览器 ssh 上我收到此错误:

    错误:VM 来宾环境已过时,仅支持已弃用的“sshKeys”元数据项。请按照此处的步骤进行更新

    即使我最终获得了访问权限,但我无法通过浏览器下载任何内容。

  • 在 ssh gcloud cli 上我收到此错误:

    权限被拒绝(publickey、gssapi-keyex、gssapi-with-mic)。错误:(gcloud.compute.ssh)[/usr/bin/ssh] 退出,返回代码为 [255]。

ssh verbose 显示以下内容:

MacBook-Pro:.ssh fcortes$ sudo gcloud compute ssh centos6 --ssh-flag="-vvv"
Password:
OpenSSH_7.9p1, LibreSSL 2.7.3
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 48: Applying options for *
debug2: resolve_canonicalize: hostname 34.66.109.207 is address
debug2: ssh_connect_direct
debug1: Connecting to 34.66.109.207 [34.66.109.207] port 22.
debug1: Connection established.
debug1: identity file /Users/fcortes/.ssh/google_compute_engine type 0
debug1: identity file /Users/fcortes/.ssh/google_compute_engine-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.9
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH_5* compat 0x0c000002
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to 34.66.109.207:22 as 'root'
debug1: using hostkeyalias: compute.8844278207473884047
debug3: hostkeys_foreach: reading file "/Users/fcortes/.ssh/google_compute_known_hosts"
debug3: record_hostkey: found key type RSA in file /Users/fcortes/.ssh/google_compute_known_hosts:1
debug3: load_hostkeys: loaded 1 keys from compute.8844278207473884047
debug3: order_hostkeyalgs: prefer hostkeyalgs: [email protected],[email protected],[email protected],rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug3: send packet: type 20
debug1: SSH2_MSG_KEXINIT sent
debug3: receive packet: type 20
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,ext-info-c
debug2: host key algorithms: [email protected],[email protected],[email protected],rsa-sha2-512,rsa-sha2-256,ssh-rsa,[email protected],[email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519
debug2: ciphers ctos: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: ciphers stoc: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,[email protected],zlib
debug2: compression stoc: none,[email protected],zlib
debug2: languages ctos: 
debug2: languages stoc: 
debug2: first_kex_follows 0 
debug2: reserved 0 
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: host key algorithms: ssh-rsa,ssh-dss
debug2: ciphers ctos: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: ciphers stoc: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: MACs ctos: hmac-md5,hmac-sha1,[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: MACs stoc: hmac-md5,hmac-sha1,[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: compression ctos: none,[email protected]
debug2: compression stoc: none,[email protected]
debug2: languages ctos: 
debug2: languages stoc: 
debug2: first_kex_follows 0 
debug2: reserved 0 
debug1: kex: algorithm: diffie-hellman-group-exchange-sha256
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes128-ctr MAC: [email protected] compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: [email protected] compression: none
debug3: send packet: type 34
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(2048<3072<8192) sent
debug3: receive packet: type 31
debug1: got SSH2_MSG_KEX_DH_GEX_GROUP
debug2: bits set: 1534/3072
debug3: send packet: type 32
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug3: receive packet: type 33
debug1: got SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: ssh-rsa SHA256:FtoD8qoSAeNtVsWukZ5YTbWIiApxpn2T+VsVzcF7SPE
debug1: using hostkeyalias: compute.8844278207473884047
debug3: hostkeys_foreach: reading file "/Users/fcortes/.ssh/google_compute_known_hosts"
debug3: record_hostkey: found key type RSA in file /Users/fcortes/.ssh/google_compute_known_hosts:1
debug3: load_hostkeys: loaded 1 keys from compute.8844278207473884047
debug1: Host 'compute.8844278207473884047' is known and matches the RSA host key.
debug1: Found key in /Users/fcortes/.ssh/google_compute_known_hosts:1
debug2: bits set: 1531/3072
debug3: send packet: type 21
debug2: set_newkeys: mode 1
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug1: SSH2_MSG_NEWKEYS received
debug2: set_newkeys: mode 0
debug1: rekey after 4294967296 blocks
debug1: Will attempt key: /Users/fcortes/.ssh/google_compute_engine RSA SHA256:CxsVOSJsVd6lZxknFbIRRlzARrtvXpyOItST5IG6mVw explicit
debug2: pubkey_prepare: done
debug3: send packet: type 5
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic
debug3: start over, passed a different list publickey,gssapi-keyex,gssapi-with-mic
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /Users/fcortes/.ssh/google_compute_engine RSA SHA256:CxsVOSJsVd6lZxknFbIRRlzARrtvXpyOItST5IG6mVw explicit
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
[email protected]: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

在我的控制台日志中,我发现唯一可能与我的问题相关的内容是:

Starting udev: udevd[351]: can not read '/etc/udev/rules.d/75-persistent-net-generator.rules'

udevd[351]: can not read '/etc/udev/rules.d/75-persistent-net-generator.rules'

但 gcloud 控制台确实显示我已经为 http 和 ssh 设置了规则

https://prnt.sc/o241br

答案1

因为数据在这里很重要,并且按照 Rick Swanson 在 Facebook 群组 Linux (RedHat/CentOS) 上的建议,rsync 是获取我的数据/备份的解决方案

我在 Digital Ocean 确实有一个测试服务器,在完成以下操作后:

rysnc -avz [backup_path_on_gcloud]/backups digitalocean_user@[digital_ocean_server_ip]

我在 gcloud 上的备份被神奇地转移到我在 digital ocean 上的测试服务器上,现在开始恢复备份

答案2

如果您在连接 GCP 中的 VM 实例时遇到问题,可以尝试以下操作之一:

  1. SSH 故障排除。您可以检查本文档中解释的场景之一是否适用于您的情况。
  2. 尝试连接到串行控制台。您应该启用它的串行控制台,将您的公共 SSH 密钥添加到项目或实例元数据中,并将您的私钥存储在您想要连接的本地机器上。
  3. 如果仍然无法连接,你可以将虚拟机实例使用的磁盘作为辅助磁盘.(跳过本文档中的“格式化磁盘”,因为它将删除所有数据)。

感谢您让我知道这些步骤是否成功。

相关内容