 
         nameFactory.next (err, uid)=>
           return callback err  if err
+
+          hostnameAlias = JVM.createAliases {
+            nickname : user.username
+            type, uid, groupSlug
+          }
+
           vm = new JVM {
             name    : "#{name}#{uid}"
             users   : [{ id: user.getId(), sudo: yes, owner: yes }]
             groups  : [{ id: group.getId() }]
+            hostnameAlias
             usage
           }
           vm.save (err) =>

          # TODO: this special case for koding should be generalized for any group.
          addVm {
            user
            target  : member
            sudo    : yes
            name    : "koding~#{member.profile.nickname}"

    JGroup  = require './group'
    JUser   = require './user'

    addVm = ({ target, user, name, sudo, groups, type })->

      uid = 0
      groupSlug = if type is 'group' then name else 'koding'
      hostnameAlias = JVM.createAliases {
        nickname : user.username
        type, uid, groupSlug
      }

      vm = new JVM {
        name: name
        users: [
          { id: user.getId(), sudo: yes, owner: yes }
        ]
        groups: groups ? []
        hostnameAlias
      }
      vm.save (err)-> target.addVm vm, handleError

