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

**URL:** <https://forum.gitea.com/t/docker-host-ssh-gitpull-push/4897>\
**Category:** 中文求助(Chinese Only)\
**Created:** [March 24, 2022, 6:43am UTC](https://forum.gitea.com/t/docker-host-ssh-gitpull-push/4897 "2022-03-24T06:43:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmu](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/jmu/32/2494_2.png) [@jmu](https://forum.gitea.com/u/jmu)\
**Post date:** [March 24, 2022, 6:43am UTC](https://forum.gitea.com/t/docker-host-ssh-gitpull-push/4897/1 "2022-03-24T06:43:17Z")

</div>

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

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

```

---

<div class="post-metadata">

**Author:** ![jmu](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/jmu/32/2494_2.png) [@jmu](https://forum.gitea.com/u/jmu)\
**Post date:** [March 30, 2022, 1:48am UTC](https://forum.gitea.com/t/docker-host-ssh-gitpull-push/4897/2 "2022-03-30T01:48:46Z")

</div>

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

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

/etc/pam.d/sshd

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

```
