diff --git a/pkg/compute/models/guest_sshable.go b/pkg/compute/models/guest_sshable.go index c6f37c71a1..662a94a3a2 100644 --- a/pkg/compute/models/guest_sshable.go +++ b/pkg/compute/models/guest_sshable.go @@ -72,6 +72,10 @@ func (guest *SGuest) GetDetailsSshable( userCred mcclient.TokenCredential, query jsonutils.JSONObject, ) (jsonutils.JSONObject, error) { + if guest.Status != compute_api.VM_RUNNING { + return nil, httperrors.NewBadRequestError("server sshable state can only be checked when in running state") + } + tryData := &GuestSshableTryData{ User: "cloudroot", }