banner
miaoer

miaoer

喵二の小博客 https://www.miaoer.net xLog 分站
tg_channel
telegram
bilibili

How to use SSH to connect to OpenWrt (CatWrt)

Because the recent Cattools and Thunder Manager require SSH for configuration, to help newcomers avoid reinventing the wheel in the blog, I will create an SSH tutorial. Once it's done, you can continue with the original blog!

Through this podcast, you can try three different SSH connection methods:

  • Termius
  • TTYD
  • Windows Terminal or CMD (OpenSSH)

Other tools are also provided with connection methods, so if you're interested, stay tuned until the end.

image

::: info
This blog will use CatWrt for demonstration throughout, and the IP in the demonstration images may not match the default.

However, all links in the text are default, assuming your IP hasn't changed, you can directly access the links for quick configuration.

Default IP: 192.168.1.4, and the password is the same as the one you use to log into the OpenWrt backend, default: password
:::

Termius#

Termius is an all-English SSH/Telnet tool. The video blog content we will create later will revolve around this software. It was chosen mainly because it provides cross-platform support, allowing synchronization between computer and mobile.

The downside is that it may frequently remind you to switch to the free plan.

In the software, click NEW HOST to create a new host. In the Address field, fill in our IP address or hostname, for example, our OpenWrt is 192.168.1.4, so we fill that in.

In the General section, under Label, add a name you like, naming it CatWrt here.

In the Credentials from Personal vault section, the Username is our account root. Click the plus sign + Password,Key,Certificate,FIDO2 below the account and select Password, then enter the password for the router backend, which is password by default for CatWrt. If you modified the password, enter your modified password.

Click Connect to successfully connect. On the first login, you need to enter and press Enter to save the key, and this is the terminal interface for OpenWrt.

image
image

TTYD#

We generally deploy TTYD on CatWrt soft routers without wireless devices. If you are using the default IP address (192.168.1.4) Click me to access CatWrt - System - TTYD Terminal

If you don't have it, you can choose to install one, but for wireless routers with limited space, it's actually unnecessary to use TTYD's Webshell feature to avoid wasting precious storage space.

CatWrt login: root
Password: 

When you see CatWrt login: first enter our account root and then press Enter when you see Password: enter the password for our router ( the password is not visible when entered).

Press Enter again to successfully connect. This is the terminal interface for OpenWrt.

image
image

TTYD may not start automatically, and you need to restart the TTYD service in System - Startup Items!

Terminal#

The Terminal here is built into Windows 11. If you are using Windows 10 and don't have it, you need to download one from Microsoft Store, or Windows 7 users can also use CMD.

You need to check if OpenSSH is installed by going to Settings - System - Optional Features to see if the OpenSSH client is available; if it is, you can skip the installation steps.

To install, click on View Features at the top, find OpenSSH, check it , and proceed to add.

Right-click on the desktop and select Open in Terminal, or press the Windows key to open the start menu and search for Terminal to open it.

Once opened, enter ssh [email protected]. There must be a space after ssh before entering root@, which represents logging in with the root account, followed by the IP address of the OpenWrt router.

On the first login, you need to enter yes and press Enter to save the key so that you won't need to confirm the key next time. The following image demonstrates the situation where you don't need to confirm the key for subsequent logins.

PS C:\Users\Cat> ssh root@10.0.0.4
The authenticity of host '10.0.0.4 (10.0.0.4)' can't be established.
ED25519 key fingerprint is SHA256:djoJMQvgOoMgk6DCPxlyfs1VvHluM2GjGw143IDbx3s.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '10.0.0.4' (ED25519) to the list of known hosts.
root@10.0.0.4's password:

This demonstrates IP: 10.0.0.4, please modify it according to your router's actual address ( the password is not visible when entered).

image

Key Error#

This error occurs because you have previously connected to the same IP, but the key corresponding to the IP has changed. This demonstrates IP: 192.168.31.1, please modify it according to your router's actual address.

PS C:\Users\Cat> ssh root@192.168.31.1
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
85:82:b1:58:20:21:a5:da:be:24:e8:14:9a:12:b2:d2.
Please contact your system administrator.
Add correct host key in C:\Users\Cat\.ssh/known_hosts to get rid of this message.
Offending ECDSA key in C:\Users\Cat\.ssh/known_hosts:5
ECDSA host key for 192.168.31.1 has changed and you have requested strict checking.
Host key verification failed.

Use this command to clear the key, or delete this file at this path C:\Users<username>.ssh/known_hosts.

ssh-keygen -R 192.168.31.1

Third-party Software#

You can use other software to replace some of the operations here, and you can compare the ease of use; the operations are generally similar, just different names.

  • Termius (feature-rich, English, easier to use)
  • TTYD (simple, some machines need to be installed separately)
  • Terminal (simple, built into Win11)
  • Putty (basic, English, easy to understand)
  • Finalshell (Chinese, easy to use, not recommended)

In conclusion, if you also want to achieve better clipboard synchronization, you can use WeChat Input Method to achieve multi-end clipboard synchronization. In the future, Miaoer’s videos will feature Termius.

Help#

Firmware support is not perfect, and bugs are inevitable. If you encounter problems, please leave a comment below or join the group to ask. If you are using my firmware, you can consult me briefly; if it's a paid service, that's even better. I won't respond to issues with others' firmware!

Feel free to leave comments to encourage ( ´・・) ノ (._.`)

This article is synchronized and updated to xLog by Mix Space. The original link is https://www.miaoer.net/posts/blog/ssh-connection-to-openwrt

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.