# File lib/fog/compute/models/aws/server.rb, line 169
        def setup(credentials = {})
          requires :identity, :public_ip_address, :username
          require 'json'

          commands = [
            %{mkdir .ssh},
            %{passwd -l #{username}},
            %{echo "#{attributes.to_json}" >> ~/attributes.json}
          ]
          if public_key
            commands << %{echo "#{public_key}" >> ~/.ssh/authorized_keys}
          end

          # wait for aws to be ready
          Timeout::timeout(360) do
            begin
              Timeout::timeout(8) do
                Fog::SSH.new(public_ip_address, username, credentials.merge(:timeout => 4)).run('pwd')
              end
            rescue Errno::ECONNREFUSED
              sleep(2)
              retry
            rescue Net::SSH::AuthenticationFailed, Timeout::Error
              retry
            end
          end
          Fog::SSH.new(public_ip_address, username, credentials).run(commands)
        end