1

I need to create a RHEL machine on GCP with separate partitions for /home, /tmp, and /var. If I were installing on a physical machine I would simply partition my disk when I install the OS but I can't seem to figure this out on a GCP virtual machine. I:

  • instantiated a new RHEL VM on GCP by selecting an existing one and the "create similar" feature
  • created a new disk on GCP with gcloud compute disks create acas-home --size 200 --type pd-ssd
  • attached it to my VM with gcloud compute instances attach-disk <my-vm-name> --disk acas-home
  • formatted it with sudo mkfs.ext4 -m 0 -E lazy_itable_init=0,lazy_journal_init=0,discard /dev/sdb
  • mounted the new partition just once in a temporary folder and copied the original .ssh folder into to to import the authorized_keys file
  • added the new disk to /etc/fstab with the following line UUID=<MY_UUID_VALUE> /home ext4 discard,defaults,nofail 0 2
  • mounted the disks with sudo mount -a
  • restarted sshd with sudo systemctl restart sshd.service

After this, I cannot ssh into the server. I tried simply deleting the authorized_keys file and creating a new one but nothing would do. I also tried adding another authorized keys file to sshd_config, and populating it, with this line but it would not pick it up either:

AuthorizedKeysFile  .ssh/authorized_keys /etc/ssh/authorized_keys 

What am I doing wrong?

Rubique
  • 11
  • 1
  • Check the ownership and permissions for the directory `~/.ssh` and the file ~/.ssh/authorized_keys`. If the settings are wrong, you cannot log in with that user ID. – John Hanley Jun 10 '21 at 18:37
  • Were you able to solve your issue ? Can you connect via SSH at all ? You may also try [serial console interactive mode](https://cloud.google.com/compute/docs/troubleshooting/troubleshooting-using-serial-console). Have a look at my other answer on [how to connect if you lost access](https://serverfault.com/a/1045717/545593). – Wojtek_B Jul 08 '21 at 10:52

2 Answers2

0

Could you please give a try following the official documentation and make the connection through gcloud:

gcloud compute ssh --project=PROJECT_ID --zone=ZONE VM_NAME

You can find more guidance in the official documentation on how to troubleshoot SSH in GCP.

Pit
  • 184
  • 11
0

You probably forgot to restore the SELinux contexts for your newly created partition.

restorecon -rv /home
Michael Hampton
  • 244,070
  • 43
  • 506
  • 972