Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker Bad owner or permissions on /root/.ssh/config

So, I've set up docker 17.03 on Ubuntu 16.04.5 LTS. The problem is, the application needs to ssh to an external server. Since docker binds current users ssh files, it should allow me to ssh into the server from the container. However its giving me the Bad owner or permissions on /root/.ssh/config error.

From what I've figured, docker is running as my ubuntu user which is 1001 and is trying to access root account ssh files (I could be wrong) which is why its giving me this error.

Also, when I run echo $USER from the container, its not returning any user, but just an empty line.

The question is, has anybody faced this problem before and if so, has anybody solved it?

like image 734
Vilius Avatar asked Aug 08 '18 10:08

Vilius


2 Answers

These commands should fix the permissions issues:

Set the file owner:

chown $USER ~/.ssh/config

Set rw for user only permissions on config:

chmod 600 ~/.ssh/config

If chmod 600 ~/.ssh/config doesn't work try with:

chmod 400 ~/.ssh/config
like image 116
juanlumn Avatar answered Sep 18 '22 23:09

juanlumn


On Linux, Changing the ownership to root fixed the issue for me. I also added my usergroup as group, so the config will work outside docker as well.

chown root:$USER ~/.ssh/config
chmod 644 ~/.ssh/config
like image 38
Morteza Rajabi Avatar answered Sep 16 '22 23:09

Morteza Rajabi