scylladb / scylla-machine-image

Apache License 2.0
18 stars 25 forks source link

azure: show login prompt correctly #434

Closed syuu1228 closed 1 year ago

syuu1228 commented 1 year ago

Currently, Azure image does not show Scylla login prompt when logging in to ssh, since /etc/skel/.profile does not copied to ~/.profile. To fix this, we need to copy the file while build the Azure image.

benipeled commented 1 year ago

Currently, Azure image does not show Scylla login prompt when logging in to ssh, since /etc/skel/.profile does not copied to ~/.profile. To fix this, we need to copy the file while build the Azure image.

That's weird. It might cause by some cleanup done by azure after the creation of the auzreuser I wondered about using /etc/profile instead of dealing with specific user(s) / provider profile files - since the instance is scylla dedicated machine we can have it on all users, WDYT?

syuu1228 commented 1 year ago

I found that this is because we create "azureuser" when start bulding machine-image, since we specify SSH_USERNAME as "azureuser", and it created before we modify /etc/skel/.profile. When we logging in to the instance, the user is already created, skel will not apply to the ~/.profile. So if we choose different username for launcing the instance, the issue won't happen.

We can fix by overwrite /home/azureuser/.profile, but I think we should drop "azureuser" at the end of machine-image building. Because, as I described above, Azure can choose username to login, there is no gurantee "azureuser" will use for the next login. Therefore, the user should create at launching the instance, not at the bulding-machine time. Once we drop it, we will have Scylla login prompt on next user creation since new /etc/skel will applied.

Also, we should do same on GCE, because same issue can happen on GCE too Why we never reproduce this on GCE is, because we normally use different username for machine-image and instance login. We specify SSH_USERNAME as "ubuntu" for GCE machine-image building, but we use local username for logging in to the instance.

I think we actually can reproduce it on GCE by following:

USER=ubuntu gcloud compute ssh $INSTANCE

Therefore, we should drop $SSH_USERNAME for both Azure and GCE, something like this:

userdel -f -r $SSH_USERNAME
syuu1228 commented 1 year ago

Updated to the new patch which drops $SSH_USERNAME user for both Azure/GCE, tested login prompt works on both Azure/GCE.

benipeled commented 1 year ago

@syuu1228 can't we use cloud-init clean for all vendors after the build?

I would expect packer to have such an option since it kind of defaults to clean images after the build (aka cloud-init / sysprep)

syuu1228 commented 1 year ago

@syuu1228 can't we use cloud-init clean for all vendors after the build?

Well, it won't clean up existing user account.

I would expect packer to have such an option since it kind of defaults to clean images after the build (aka cloud-init / sysprep)

Seems like Packer doesn't have such option. I found there is an option to clean up ~/.ssh/authorized_keys but no option to clean up user account entirely.