> For the complete documentation index, see [llms.txt](https://termux-wiki.zsxwz.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://termux-wiki.zsxwz.com/ssh-lian-jie.md).

# 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`
