# File lib/fog/rackspace/models/compute_v2/server.rb, line 623
        def setup(credentials = {})
          requires :ssh_ip_address, :identity, :public_key, :username

          retried_disconnect = false

          commands = [
            %{mkdir .ssh},
            %{echo "#{public_key}" >> ~/.ssh/authorized_keys},
            password_lock,
            %{echo "#{Fog::JSON.encode(attributes)}" >> ~/attributes.json},
            %{echo "#{Fog::JSON.encode(metadata)}" >> ~/metadata.json}
          ]
          commands.compact

          self.password = nil if password_lock

          Fog::SSH.new(ssh_ip_address, username, credentials).run(commands)
        rescue Errno::ECONNREFUSED
          sleep(1)
          retry
        # Ubuntu 12.04 images seem to be disconnecting during the ssh setup process.
        # This rescue block is an effort to address that issue.
        rescue Net::SSH::Disconnect
          unless retried_disconnect
            retried_disconnect = true
            sleep(1)
            retry
          end
        end