使用Docker+host转发ssh时, gitpull/push有点卡卡的

实际体感整个过程时2-3秒左右, 看日志倒是很短
感觉到了服务端的时间比较长, 怀疑时ssh建立连接时间有点长了。

Accepted publickey for git from 172.25.0.1 port 54318 ssh2: RSA SHA256:<删了>
2022/03/24 14:40:35 Started GET /api/internal/serv/command/5/jmu/hecto?mode=1&verb=git-upload-pack for 127.0.0.1:45518
2022/03/24 14:40:35 ...ters/private/serv.go:412:ServCommand() [D] Serv Results:
	IsWiki: false
	DeployKeyID: 0
	KeyID: 5	KeyName: xxx@gmail.com-pi
	UserName: jmu
	UserID: 1
	OwnerName: jmu
	RepoName: hecto
	RepoID: 5
2022/03/24 14:40:35 Completed GET /api/internal/serv/command/5/jmu/hecto?mode=1&verb=git-upload-pack 200 OK in 18.104806ms
2022/03/24 14:40:35 Started POST /api/internal/ssh/5/update/5 for 127.0.0.1:45522
2022/03/24 14:40:35 Completed POST /api/internal/ssh/5/update/5 200 OK in 8.106542ms
Received disconnect from 172.25.0.1 port 54318:11: disconnected by user
Disconnected from user git 172.25.0.1 port 54318

自己查了一下, 这种shim模式是要转git的用户login到宿主机。 我用的Ubuntu登录执行比较慢导致的。

解决方法是注释掉以下文件的2个session项目

/etc/pam.d/sshd

# Print the message of the day upon successful login.
# This includes a dynamically generated part from /run/motd.dynamic
# and a static (admin-editable) part from /etc/motd.
session    optional     pam_motd.so  motd=/run/motd.dynamic
session    optional     pam_motd.so noupdate