LoginSignup
11
9

More than 3 years have passed since last update.

Githubに繋ごうとすると\337\376hでエラーが出る

Last updated at Posted at 2019-09-06

環境

windows10
git 2.21.0.windows.1

ssh接続できていない

SSHの鍵の設定をしてからリポジトリを作成し、初めてのpushをしようとすると

$ ssh push origin master
/c/Users/hoge/.ssh/config: line 1: Bad configuration option: \377\376h
/c/Users/hoge/.ssh/config: terminating, 1 bad configuration options
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

と出る。
ssh接続できていないといわれたので確認してみる。

$ ssh -T git@github.com
/c/Users/hoge/.ssh/config: line 1: Bad configuration option: \377\376h
/c/Users/hoge/.ssh/config: terminating, 1 bad configuration options

同様のエラーが出るのでやはり繋がっていないらしい。
configファイルの設定がおかしいらしいが、ファイル中に\377\376hという記述はみつからない。

IgnoreUnknownを指定してみる

$ vi ~/.ssh/config

でvimを開いてファイル中に

IgnoreUnknown \377\376h

を先頭に記述。

$ ssh -T git@github.com
/c/Users/hoge/.ssh/config: line 1: Bad configuration option: \377\376i
/c/Users/hoge/.ssh/config: terminating, 1 bad configuration options

なぜか\377\376iに名前を変えてきた。

ググった

powershellからconfigファイルを作成するとUTF-16 LEでエンコードされたファイルが作成される。これがいけないらしい。(cmdやgit bash、エディタからだと回避できる模様)
実際VSCodeで開いてみたらUTF-16 LEになっていた。
これをUTF-8にして保存する。

$ ssh -T git@github.com
The authenticity of host 'hoge' can't be established.
RSA key fingerprint is SHA256:hogehoge
Are you sure you want to continue connecting (yes/no)? 

yesを入力してパスワードも入力

Hi hoge! You've successfully authenticated, but GitHub does not provide shell access.

で き た

無事pushもできました

参考

11
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
9