SnapOverflow

SnapOverflow Logo SnapOverflow Logo

SnapOverflow Navigation

  • Home
  • Server
  • Ubuntu

Mobile menu

Close
  • Home
  • System Administrators
    • Hot Questions
    • New Questions
    • Tags
  • Ubuntu
    • Hot Questions
    • New Questions
    • Tags
  • Help
Home / server / Questions / 253313
Accepted
Robert
Robert
Asked: 2011-03-30 10:15:48 +0800 CST2011-03-30 10:15:48 +0800 CST 2011-03-30 10:15:48 +0800 CST

ssh returns "Bad owner or permissions on ~/.ssh/config"

  • 772

When I try to ssh to another box, I get this strange error

$ ssh hostname
Bad owner or permissions on ~/.ssh/config

But I made sure that I own and have rw permissions on the file:

ls -la ~/.ssh/
total 40K
drwx------ 2 robert robert 4.0K Mar 29 11:04 ./
drwx------ 7 robert robert 4.0K Mar 29 11:04 ../
-rw-r--r-- 1 robert robert 2.0K Mar 17 20:47 authorized_keys
-rw-rw-r-- 1 robert robert   31 Mar 29 11:04 config
-rw------- 1 robert robert 1.7K Aug  4  2010 id_rsa
-rw-r--r-- 1 robert robert  406 Aug  4  2010 id_rsa.pub
-rw-r--r-- 1 robert robert 6.1K Mar 29 11:03 known_hosts
ssh file-permissions
  • 6 6 Answers
  • 479160 Views

6 Answers

  • Voted
  1. Best Answer
    Robert
    2011-03-30T10:16:56+08:002011-03-30T10:16:56+08:00

    I needed to have rw for user only permissions on config. This fixed it.

    chmod 600 ~/.ssh/config
    

    As others have noted below, it could be the file owner. (upvote them!)

    chown $USER ~/.ssh/config
    

    If your whole folder has invalid permissions here's a table of possible permissions:

    Path Permission
    .ssh directory (code) 0700 (drwx------)
    private keys (ex: id_rsa) (code) 0600 (-rw-------)
    config 0600 (-rw-------)
    public keys (*.pub ex: id_rsa.pub) 0644 (-rw-r--r--)
    authorized_keys (code) 0644 (-rw-r--r--)
    known_hosts 0644 (-rw-r--r--)

    Sources:

    • openssh check-perm.c
    • openssh readconf.c
    • openssh ssh_user_config fix_authorized_keys_perms
    • 857
  2. kenorb
    2015-08-04T03:30:04+08:002015-08-04T03:30:04+08:00

    These commands should fix the permission problem:

    chown $USER ~/.ssh/config
    chmod 644 ~/.ssh/config
    

    Prefix with sudo if the files are owned by different user (or you don't have access to them).

    If more files are affected, replace config with *.

    In man ssh we can read:

    Because of the potential for abuse, this file must have strict permissions: read/write for the user, and not writable by others. It may be group-writable provided that the group in question contains only the user.

    • 108
  3. svnm
    2015-05-28T17:07:58+08:002015-05-28T17:07:58+08:00

    For me it was an issue with my user account not being the owner of the file

    sudo chown myuser ~/.ssh/config
    
    • 18
  4. Nathan Kidd
    2019-08-23T11:26:52+08:002019-08-23T11:26:52+08:00

    If on Windows Subsystem for Linux (WSL) and you pointed your WSL home directory to your Windows home directory (not recommended!) then chmod has no effect. Before you can chmod the files mentioned in other answers you must add

    [automount]
    options = "metadata"
    

    to your /etc/wsl.conf then restart WSL (requires build 17093 or later).

    Before mount says:

    C: on /mnt/c type drvfs (rw,noatime,uid=1000,gid=1000,case=off)
    

    After mount says:

    C: on /mnt/c type drvfs (rw,noatime,uid=1000,gid=1000,metadata,case=off)
    
    • 14
  5. Alexander Gavriliuk
    2020-01-14T13:10:48+08:002020-01-14T13:10:48+08:00

    Don't forget about the group:

    chown $USER:$USER ~/.ssh/config
    

    :-)

    • 3
  6. Jeff Tian
    2020-02-27T20:02:58+08:002020-02-27T20:02:58+08:00

    I met this issue on windows 10 with vagrant ssh. And tried all the above methods, but get no luck. Finally I deleted that ssh config file and then it works!

    vagrant ssh
    Bad owner or permissions on C:\\Users\\Jeff/.ssh/config
    del ..\.ssh\config
    
    vagrant ssh
    Welcome to Ubuntu 14.04.6 LTS (GNU/Linux 3.13.0-170-generic x86_64)
    
     * Documentation:  https://help.ubuntu.com/
    
      System information as of Thu Feb 27 02:23:03 UTC 2020
    
      System load:  0.0               Processes:              77
      Usage of /:   5.1% of 39.34GB   Users logged in:        0
      Memory usage: 21%               IP address for eth0:    10.0.2.15
      Swap usage:   0%                IP address for docker0: 172.17.0.1
    
      Graph this data and manage this system at:
        https://landscape.canonical.com/
    
    New release '16.04.6 LTS' available.
    Run 'do-release-upgrade' to upgrade to it.
    
    
    vagrant@vagrant-ubuntu-trusty-64:~$
    
    
    • 1

Sidebar

Stats

  • Questions 681965
  • Answers 980273
  • Best Answers 280204
  • Users 287326
  • Popular
  • Answers
  • Marko Smith

    Ping a Specific Port

    • 18 Answers
  • Marko Smith

    Check if port is open or closed on a Linux server?

    • 7 Answers
  • Marko Smith

    How to automate SSH login with password?

    • 10 Answers
  • Marko Smith

    How do I tell Git for Windows where to find my private RSA key?

    • 30 Answers
  • Marko Smith

    What's the default superuser username/password for postgres after a new install?

    • 5 Answers
  • Marko Smith

    What port does SFTP use?

    • 6 Answers
  • Marko Smith

    Resolve host name from IP address

    • 8 Answers
  • Marko Smith

    Command line to list users in a Windows Active Directory group?

    • 9 Answers
  • Marko Smith

    What is a Pem file and how does it differ from other OpenSSL Generated Key File Formats?

    • 3 Answers
  • Marko Smith

    How to determine if a bash variable is empty?

    • 15 Answers
  • Martin Hope
    Davie Ping a Specific Port 2009-10-09 01:57:50 +0800 CST
  • Martin Hope
    Smudge Our security auditor is an idiot. How do I give him the information he wants? 2011-07-23 14:44:34 +0800 CST
  • Martin Hope
    kernel Can scp copy directories recursively? 2011-04-29 20:24:45 +0800 CST
  • Martin Hope
    Robert ssh returns "Bad owner or permissions on ~/.ssh/config" 2011-03-30 10:15:48 +0800 CST
  • Martin Hope
    Eonil How to automate SSH login with password? 2011-03-02 03:07:12 +0800 CST
  • Martin Hope
    gunwin How do I deal with a compromised server? 2011-01-03 13:31:27 +0800 CST
  • Martin Hope
    Tom Feiner How can I sort du -h output by size 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich What is a Pem file and how does it differ from other OpenSSL Generated Key File Formats? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent How to determine if a bash variable is empty? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus How do you find what process is holding a file open in Windows? 2009-05-01 16:47:16 +0800 CST

Related Questions

Trending Tags

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • Home
  • Questions
    • Hot Questions
    • New Questions
  • Tags
  • Help

Footer

SnapOverflow

About Us

  • About Us
  • Contact Us

Legal Stuff

  • Privacy Policy

Help

© 2022 SOF-TR. All Rights Reserve