AlexxIT / XiaomiGateway3

Home Assistant custom component for control Xiaomi Multimode Gateway (aka Gateway 3), Xiaomi Multimode Gateway 2, Aqara Hub E1 on default firmwares over LAN
https://github.com/AlexxIT/Blog
MIT License
2.47k stars 348 forks source link

Reviving Telnet access on Xiaomi Gateway 3 ZNDMWG04LM after getting key using UART Method. #1465

Open jksmurf opened 1 month ago

jksmurf commented 1 month ago

I have a ZNDMWG04LM with 1.07_0019 FW.

I did the UART connection and checked the output and succesfully got the Key (not the Token), based on [methods detailed in 1166]. This allowed me to ADD it to AlexxIT's Gateway 3 interface. In fact I did two of them. (https://github.com/AlexxIT/XiaomiGateway3/issues/1166).

My question however is about the need for telnet following integration; I can access the Gateway menu using Putty, but no Admin/Password pair matches, so I cannot actually log in. I tried admin/admin, admin/blank, admin/123123 and a few other combinations. I tried the 5-2-2-2-2-2-2 setting.

Thx IMG_E0823

AlexxIT commented 1 month ago

This model has root user with blank password (after adding to integration).

jksmurf commented 1 month ago

Yes, I can get to the # prompt but it doesn't look like a screen you normally see when you logon using putty.

Root Blank

AlexxIT commented 1 month ago

You're in an empty folder. That's why ls doesn't show anything.

jksmurf commented 1 month ago

Putty

Thank you. Is there a way to WinSCP into these Gateways, I just find it easier to use WinSCP to check folders/files, but I keep getting connection refused?

AlexxIT commented 1 month ago

https://github.com/AlexxIT/XiaomiGateway3/blob/0acd959050bc221225c7377c3113f4976cd482d3/custom_components/xiaomi_gateway3/core/shell/shell_e1.py#L71-L72

jksmurf commented 1 month ago

https://github.com/AlexxIT/XiaomiGateway3/blob/0acd959050bc221225c7377c3113f4976cd482d3/custom_components/xiaomi_gateway3/core/shell/shell_e1.py#L71-L72

Thank you AlexxIT, but I’m sorry that’s just gone way over my head. I’ve no idea what to do with that 🙏

AlexxIT commented 1 month ago

This is command for run FTP

jksmurf commented 1 month ago

Thanks @AlexxIT.

I did a bit of searching around based on that information and got it to work, so for the benefit of others wanting to use WinSCP to poke around in the Gateway File System (own risk!), I jotted down a few steps:

  1. After you have removed the password using the UART approach, then login to the Gateway using Putty, username 'root' and no password (just hit enter);

  2. After you login using Putty, IF you WANT to add a password back (you do not have to!), issuing this (where #!/bin/sh is the prompt in Putty, you might just see a '#' per the pics and not '#!/bin/sh'), will change the password to "xxxxxx"; remember the new password!

#!/bin/sh
echo "root:xxxxxx" | chpasswd

Note: If you add a password (please remember it!) and want to revert back to NO password, after you login (with your current password), just run:

#!/bin/sh
echo "root:" | chpasswd

Note a: If you do the above (echo "root:" | chpasswd) Putty will now give you a password prompt, just hit 'Enter' to login i.e. No Password.

Note b: If you want to delete the password for the user root (i.e. return it to the completely removed password state post UART), issue this at the prompt:

#!/bin/sh
passwd -d root
  1. After you login via Putty, issuing this (where #!/bin/sh is the prompt in Putty), will give you WinSCP access via FTP:
#!/bin/sh
/usr/sbin/telnetd
/usr/bin/tcpsvd -E 0.0.0.0 21 ftpd -w / &

I believe you only need to issue it once (maybe unless you reboot the device).

  1. After Step 3, go to WinSCP, make a new profile using the FTP protocol, using your IP Address, Port 21, user root and (no password unless you added one); no encryption, you're in!

This was my experience, the brief writeup is for users at my level of expertise (low!). There may be other or more correct ways to do these things and I would be happy to have someone add or correct me, no offense.

HTH

k.

1-Error message without setting up FTP 2-Putty_to_XiaomiGateway 3-Set WinSCP Access 4-Gateway on which I changed the PWD then Back to Blank 5-Xiaomi GatewayWiNSCP_Profile 6-WinSCP Access You are In 7  passwd -d root