# ssh连接

1. windows或者linux远程ssh连接termux：

```
# 安装ssh服务
pkg install openssh

# 启动sshd
sshd

# 设置termux密码
passwd

# 查看用户名
whoami
```

由于linux系统限制，没有root权限不能使用1024以下端口。因此termux默认ssh端口为8022,

ssh连接：

```
ssh -P 8022 user@192.168.xxx.xxx
```

如果使用密钥会比较麻烦一点，但也更安全一点。

可以参考： <https://bbs.zsxwz.com/thread-2368.htm>

2\. termux远程ssh连接其他linux或者windows：

```
ssh -P 22 root@xxx.xxx.xxx.xxx
```

如果觉得每一次都需要输入一串密码，比较麻烦，可以设置密钥登录。

可以参考：\
ssh连接linux： <https://bbs.zsxwz.com/thread-2265.htm>\
ssh连接windows：<https://bbs.zsxwz.com/thread-5183.htm>

添加ssh配置文件：.ssh/config

```
Host xxx # 设置别名
HostName xxx.xxx.xxx.xxx # ip地址
User root # 用户
Port 1024 # 端口
IdentityFile ~/.ssh/xxx # 验证文件
```

ssh连接：`ssh xxx`


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://termux-wiki.zsxwz.com/ssh-lian-jie.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
