All-Hands-AI / OpenHands

🙌 OpenHands: Code Less, Make More
https://all-hands.dev
MIT License
36.06k stars 4.11k forks source link

[Bug]: Need help with multiple connection error I am seeing #4611

Open Prabhu-Kailash opened 2 weeks ago

Prabhu-Kailash commented 2 weeks ago

Is there an existing issue for the same bug?

Describe the bug and reproduction steps

Getting multiple different errors while trying to log into a remote server server (From MacOS or Linux Rocky8).

could not set shell prompt (received: b"unset PROMPT_COMMAND\r\nPS1='[PEXPECT]\\$ '\r\nset prompt='[PEXPECT]\\$ '\r\nprompt restore;\r\nPS1='[PEXPECT]%(!.#.$) '\r\n", expected: '\\[PEXPECT\\][\\$\\#] ').

could not synchronize with original prompt

could not set shell prompt (received: b"unset PROMPT_COMMAND\r\nPS1='[PEXPECT]\\$ '\r\nLast login: Tue Oct 29 14:22:38 2024 from 10.166.122.120\r\r\n[user@remoteserver ~]$ \r\n[user@remoteserver ~]$ \r\n[user@remoteserver ~]$ \r\n[user@remoteserver ~]$ \r\n[user@remoteserver ~]$ unset PROMPT_COMMAND\r\n", expected: '\\[PEXPECT\\][\\$\\#] ').

Script I am using to login,

      attempt = 0
      while attempt < 5:
              try:
                  s = pxssh.pxssh(options={"UserKnownHostsFile": "/dev/null", "StrictHostKeyChecking": "no"},
                                  timeout=60)
                  s.login(host, 'user', ssh_key=get_ssh_key(), sync_multiplier=10, port=22)
                  s.sendline('sudo systemctl restart servicename')
                  s.prompt()
              except Exception as e:
                  logging.info(f"Attempt {attempt + 1}: {e}")
                  if 'could not synchronize with original prompt' in str(e):
                      # Optionally unset the prompt or adjust as needed
                      print("Adjusting prompt...")
                      s.prompt_command = None  # Unset the prompt_command
                      # Optionally modify the prompt pattern
                      s.prompt = pexpect.EOF
                  attempt += 1

Help me on how to get this resolved.

OpenHands Installation

Docker command in README

OpenHands Version

No response

Operating System

MacOS

Logs, Errors, Screenshots, and Additional Context

could not synchronize with original prompt

could not set shell prompt (received: b"unset PROMPT_COMMAND\r\nPS1='[PEXPECT]\$ '\r\nLast login: Tue Oct 29 14:22:38 2024 from 10.166.122.120\r\r\n[user@remoteserver ~]$ \r\n[user@remoteserver ~]$ \r\n[user@remoteserver ~]$ \r\n[user@remoteserver ~]$ \r\n[user@remoteserver ~]$ unset PROMPT_COMMAND\r\n", expected: '\[PEXPECT\][\$\#] ')

mamoodi commented 1 week ago

So you have OpenHands running and you tell it to login to a remote server of some kind? That's probably unsupported. Not sure what the use case is.