连接
-i指定密钥
-o加option
1
2-o TCPKeepAlive=yes //长连接
-o ServerAliveInterval=30 //
端口转发
1 | ssh -L local_port:localhost:remote_port -N -T user@server_address -p server_ssh_port |
配置
config文件配置: ~/.ssh/config
1
2
3
4
5
6
7
8#配置
Host gitee.com
HostName gitee.com
IdentityFile xxx/xxx/_id_rsa
PreferredAuthentications publickey
User xxx
TCPKeepAlive=yes
ServerAliveInterval 60配置服务端
- 件位置,全局位置: /etc/ssh/sshd_config
- 文件位置,termux: $PREFIX/etc/ssh/sshd_config
- 配置:
- PasswordAuthentication (密码验证) yes/no
- 启用密钥验证
- RSAAuthentication (rsa秘钥) yes/no
- PubkeyAuthentication (公钥) yes/no
- 认证秘钥,将公钥写入该文件(authorized_keys),就可使用该公钥登陆
- 位置: ~/.authorized_keys
工具
windows terminal
1
2
3
4
5
6
7
8
9
10连接远程机器使用 ssh 配置
{
"guid": "{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}",
"hidden": false,
"name": "xxxxxxx",
//密钥放在本地,-i 指定密钥位置
"commandline": "ssh -i xxxxxxx_id_rsa user@host -p xxxxxxxx -o TCPKeepAlive=yes -o ServerAliveInterval=30",
"startingDirectory": "/home/xxxxxxx",
"icon" : "ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png"
}