使用bash脚本执行git clone,无法读取存储库的密码

时间:2018-01-12 15:51:46

标签: linux bash git amazon-ec2 amazon-cloudformation

我尝试通过CloudFormation部署Amazon EC2实例,并尝试使用带有cfn-init的bash脚本克隆存储库。

"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
                "#! /bin/bash -xe\n",
                "yum install -y aws-cfn-bootstrap\n",
                "/opt/aws/bin/cfn-init -v ",
                "       --stack ", { "Ref" : "AWS::StackName" },
                "       --resource DocumentationInstance ",
                "       --configsets Install ",
                "       --region ", { "Ref" : "AWS::Region" }, "\n",
                "git clone https://", { "Ref": "GitLabUsn" },"@gitlab.com/user/repository.git \n", { "Ref": "GitLabPwd" }  
                ]]}}
        }

但是,当我部署EC2实例时,我可以从cloud-init-output.log看到git clone失败,这就是错误:

fatal: could not read Password for 'https://username@gitlab.com': No such device or address

如何正确输入bash脚本的密码?我已经尝试yes找到了here

1 个答案:

答案 0 :(得分:1)

添加这样的密码(您也可以将其设置为参数) Impl

在您的情况下,它将是:

git clone https://user:password@gitlab.com/....git