【问题标题】:.ssh/config: line 1: Bad configuration option: \342\200\234host.ssh/config:第 1 行:错误的配置选项:\342\200\234host
【发布时间】:2021-01-19 18:47:13
【问题描述】:

我正在尝试将代码从 GitLab 部署到 EC2 实例。但是,当我运行管道时出现以下错误

/home/gitlab-runner/.ssh/config: line 1: Bad configuration option: \342\200\234host
/home/gitlab-runner/.ssh/config: terminating, 1 bad configuration options

这是我正在使用的 .gitlab-ci.yml 文件。

stages:
   - QAenv
   - Prod
Deploy to Staging:
  stage: QAenv
  tags:
    - QA
  before_script:
    # Generates to connect to the AWS unit the SSH key.
    - mkdir -p ~/.ssh
    - echo -e “$SSH_PRIVATE_KEY” > ~/.ssh/id_rsa
    # Sets the permission to 600 to prevent a problem with AWS
    # that it’s too unprotected.
    - chmod 600 ~/.ssh/id_rsa
    - 'echo -e “Host *\n\tStrictHostKeyChecking no\n\n” > ~/.ssh/config'
  script:     
    - bash ./gitlab-deploy/.gitlab-deploy.staging.sh   
  environment:     
    name: QAenv     
    # Exposes a button that when clicked take you to the defined URL:
    url: https://your.url.com   

下面是我设置的 .gitlab-deploy.staging.sh 文件以部署到我的服务器。

# !/bin/bash
# Get servers list:
set — f
# Variables from GitLab server:
# Note: They can’t have spaces!!
string=$DEPLOY_SERVER
array=(${string//,/ })
for i in "${!array[@]}"; do
  echo "Deploy project on server ${array[i]}"
  ssh ubuntu@${array[i]} "cd /opt/bau && git pull origin master"
done

我检查了我的 .ssh/config 文件内容,下面是我可以看到的内容。

ubuntu@:/home/gitlab-runner/.ssh$ cat config 
“Host *ntStrictHostKeyChecking nonn”

关于我做错了什么以及我应该做出哪些改变有什么想法吗?

【问题讨论】:

  • "替换所有
  • 顺便说一句:将# ! 替换为#!
  • 您还需要修正右引号。

标签: bash git amazon-web-services amazon-ec2 gitlab


【解决方案1】:

问题出在。

ubuntu@ip-172-31-42-114:/home/gitlab-runner/.ssh$ cat config 
“Host *ntStrictHostKeyChecking nonn”

因为这里有一些 Unicode 字符,通常在我们从文档或网页中复制粘贴代码时出现。

在您的情况下,这个 字符也可以在输出中看到。

将其替换为 " 并检查配置中的其他内容,更新应该可以工作。

这个问题getting errors stray ‘\342’ and ‘\200’ and ‘\214’有更多细节

【讨论】:

    猜你喜欢
    • 2013-04-13
    • 2021-11-11
    • 1970-01-01
    • 1970-01-01
    • 2021-03-06
    • 2015-01-20
    • 1970-01-01
    • 1970-01-01
    • 2018-05-07
    相关资源
    最近更新 更多