我使用 terraform 创建了数据库,其数据库系统如下:
resource "oci_database_db_system" "test_db_system" {
availability_domain = data.oci_identity_availability_domains.ADs.availability_domains[0].name
compartment_id = oci_identity_compartment.Compartment.id
database_edition = "STANDARD_EDITION"
db_home {
database {
admin_password = var.db_password
db_name = "database"
pdb_name = "pdb"
db_backup_config {
auto_backup_enabled = false
}
}
db_version = "19.10.0.0"
display_name = "MyTFDBHomeVm"
}
db_system_options {
storage_management = "LVM"
}
shape = "VM.Standard2.2"
subnet_id = oci_core_subnet.ExampleSubnet.id
ssh_public_keys = [ file("C:\\Users\\USERNAME\\.ssh\\PUBLIC_KEY_FILE") ]
display_name = "MyTFDBSystemVM"
hostname = "testhostname"
data_storage_size_in_gb = 256
license_model = "BRING_YOUR_OWN_LICENSE"
node_count = 1
}
然后我尝试使用以下命令通过 ssh 进入数据库(我在 Windows 10 上,使用 git bash)。公钥来自 oci 控制台中的节点选项卡。
ssh -i /c/Users/USERNAME/.ssh/PRIVATE_KEY oracle@PUBLIC_IP
我收到以下错误
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
我也尝试在 OCI 控制台中生成密钥,但使用它进行连接也不起作用。我最后尝试的是从正在创建的计算实例进行 ssh,得到了同样的错误。
答案1
我使用了错误的用户名!就是这样,它应该是 opc,所以 ssh 命令应该像
ssh -i /c/Users/USERNAME/.ssh/PRIVATE_KEY opc@PUBLIC_IP