SSH

来自OSSmedia
Brucekomike讨论 | 贡献2024年5月28日 (二) 11:26的版本

ssh是用来连接其他电脑的工具软件,广泛用于服务器运维。

客户端配置

用户的配置文件位于 ~/.ssh/config 下。

参数

禁用局域网内部的主机密钥检查

Host 192.168.*.*
 UserKnownHostsFile /dev/null
 StrictHostKeyChecking no

为github配置ssh

Host github
 User git
 HostName github.com
 IdentityFile ~/.ssh/github
 ProxyCommand nc -X 5 -x 127.0.0.1:2080 %h %p

ssh over ssl

Host ossmedia
 HostName ossmedia.cn
 ProxyCommand openssl s_client -quiet -servername <host> -connect <host:port>
 User username

默认为所有ssh目标主机配置代理

Host *
  RemoteForward 12321 127.0.0.1:2080

使用多个配置文件

Include config.d/home

服务端配置

服务器

UseDNS no
AddressFamily inet
SyslogFacility AUTHPRIV
PermitRootLogin no
PasswordAuthentication yes

TCPKeepAlive yes
ClientAliveInterval 100
ClientAliveCountMax 240

局域网

PermitRootLogin no
PasswordAuthentication no
PubkeyAuthentication no
Match Address 192.168.*
       PermitRootLogin yes
       PasswordAuthentication yes
       PubkeyAuthentication yes

错误排查

详见SSH/错误排查