現象
gitコマンドからは問題なく操作出来るが、
protodep経由だとgitからClone出来なくて困った。
$ protodep up -f
[INFO] force update = true
[INFO] cleanup cache = false
[INFO] identity file =
[INFO] use https = false
[INFO] Getting github.com/ft-labo/${リポジトリ名} 🕐 Error: clone repository is failed: knownhosts: /Users/mitsuaki1229/.ssh/known_hosts:5: illegal base64 data at input byte 372
Usage:
protodep up [flags]
Flags:
--basic-auth-password string set the password or personal access token(when enabled 2FA) with Basic Auth via HTTPS
--basic-auth-username string set the username with Basic Auth via HTTPS
-c, --cleanup cleanup cache before exec.
-f, --force update locked file and .proto vendors
-h, --help help for up
-i, --identity-file string set the identity file for SSH
-p, --password string set the password for SSH
-u, --use-https use HTTPS to get dependencies.
clone repository is failed: knownhosts: /Users/mitsuaki1229/.ssh/known_hosts:5: illegal base64 data at input byte 372
原因
known_hostsに改行されずに保存されているエントリが存在した。
例
127.0.0.1 ssh-rsa 44OU44Kr44OB44Ol44Km44GS44KT44GN44Gn44Gh44KF44GG127.0.0.1 ecdsa-sha2-nistp256 44Gq44KT44Gn44Ko44Oz44K444OL44Ki44Gv54yr44GM5aW944GN44Gq44KT44Gg44KN44GG44GL44CC54is6Jmr6aGe44KC5Y+v5oSb44GE44Go5oCd44GG44KT44Gg44GR44Gp44Gq44O844CC44GE44KE44G+44GB54yr44KC5aW944GN44Gq44KT44Gg44GR44Gp44CC
解決
改行後
127.0.0.1 ssh-rsa 44OU44Kr44OB44Ol44Km44GS44KT44GN44Gn44Gh44KF44GG
127.0.0.1 ecdsa-sha2-nistp256 44Gq44KT44Gn44Ko44Oz44K444OL44Ki44Gv54yr44GM5aW944GN44Gq44KT44Gg44KN44GG44GL44CC54is6Jmr6aGe44KC5Y+v5oSb44GE44Go5oCd44GG44KT44Gg44GR44Gp44Gq44O844CC44GE44KE44G+44GB54yr44KC5aW944GN44Gq44KT44Gg44GR44Gp44CC
再実行
$ protodep up -f
[INFO] force update = true
[INFO] cleanup cache = false
[INFO] identity file =
[INFO] use https = false
[INFO] Getting github.com/ft-labo/${リポジトリ名}
mitsuaki1229@mitsuaki1229-mba-ftl:
解析
protodepのソースを見る限り、NewPublicKeysFromFileの先々にて、pem.goのDecodeを使って、ファイル内の行に対して、base64のエンコードをしてる模様。
known_hostsの改行されずにくっついてる残りの行に対して、base64エンコードをしようとしてるため、illegal base64 data at input byte
が出てるように見える。
URL: r.authProvider.GetRepositoryURL(reponame),
})
if err != nil {
return nil, errors.Wrap(err, "clone repository is failed")
am, err := ssh.NewPublicKeysFromFile("git", p.pemFile, p.password)
go/1.16.3/libexec/src/encoding/pem/pem.go
Decodeの該当箇所。
base64Data := removeSpacesAndTabs(rest[:endIndex])
p.Bytes = make([]byte, base64.StdEncoding.DecodedLen(len(base64Data)))
n, err := base64.StdEncoding.Decode(p.Bytes, base64Data)