Login to server by ssh as other user than ROOT
I tried set CI/CD in .gitlab-ci.yml, but I can't resolve problem with permission to the private key. My config
- deploy
deploy_staging:
stage: deploy
before_script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- mkdir -p ~/.ssh
- chmod 400 ~/.ssh
- echo "$SSH_PRIVATE_KEY" | ssh-add - > ~/.ssh/id_rsa
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
script:
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- ssh -p22 xxx@xxx
environment:
name: staging
url :xxx
pipline does not pass and return an error :
Warning: Permanently added 's13.zenbox.pl,2.57.137.13' (ECDSA) to the list of known hosts.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for '/root/.ssh/id_rsa' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "/root/.ssh/id_rsa": bad permissions
Permission denied, please try again.
Permission denied, please try again.
xxx@xxx: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
as you can see, ssh tries get access to /root/.ssh , but my application is developed on shared hosting and I don't access to root user. I think that it can be relating to the docker executor. I was reading that default use user is root. Can I change it?
Edited by Pablosssoo