Today I started up my iTerm
and I'm getting permission denied for most of my commands in terminal
.
For example if I run pbcopy < ~/.ssh/id_rsa.pub
I get the output permission denied: /Users/coreyvincent/.ssh/id_rsa.pub
I'm also getting permission denied (public key)
when I try to ssh into my web app, which was the first instance where I found that my commands were not working.
Not sure what caused this or how to fix it. I've tried re-adding my public keys(ssh-keygen), and I've tried a couple chmod
commands, but I don't really know what I'm doing there.
ls -l
total 301
drwxrwxr-x+ 157 root admin 5338 Feb 8 17:30 Applications
drwxrwxr-x 6 root admin 204 Apr 17 2015 Developer
drwxrwxr-x 10 root admin 340 Oct 22 2014 Incompatible Software
drwxr-xr-x+ 77 root wheel 2618 Nov 8 2016 Library
drwxr-xr-x 3 coreyvincent wheel 102 Sep 8 2016 Log
drwxr-xr-x@ 2 root wheel 68 Sep 9 2014 Network
-rw-r--r--@ 1 coreyvincent admin 1 Oct 24 2008 Shockwave Log
drwxr-xr-x+ 4 root wheel 136 Oct 21 2014 System
lrwxr-xr-x 1 root wheel 49 Jun 19 2012 User Information -> /Library/Documentation/User Information.localized
drwxr-xr-x 7 root admin 238 Nov 18 2016 Users
-rw-r--r-- 1 coreyvincent admin 396 Sep 23 2008 Users:coreyvincent:Library:Application Support:Adobe:Dreamweaver 9:Configurationssh_hosts
drwxrwxrwt@ 3 root admin 102 Feb 9 07:27 Volumes
drwxr-xr-x@ 39 root wheel 1326 Aug 24 2015 bin
drwxrwxr-t@ 2 root admin 68 Sep 9 2014 cores
dr-xr-xr-x 3 root wheel 4538 Feb 8 17:24 dev
-rw-r--r-- 1 coreyvincent wheel 59919 Jul 8 2016 dex_Log.html
-rw-r--r-- 1 coreyvincent wheel 39883 Jul 8 2016 dex_Log.txt
lrwxr-xr-x@ 1 root wheel 11 Oct 21 2014 etc -> private/etc
dr-xr-xr-x 2 root wheel 1 Feb 9 09:48 home
-rw-r--r--@ 1 root wheel 313 Oct 1 2014 installer.failurerequests
-rw-r--r-- 1 coreyvincent wheel 4676 Apr 29 2015 launcher.log
-rw-r--r-- 1 coreyvincent wheel 141 Jul 12 2017 log.out
dr-xr-xr-x 2 root wheel 1 Feb 9 09:48 net
drwxr-xr-x@ 5 root wheel 170 Nov 21 07:41 opt
drwx------ 24 coreyvincent wheel 816 Jan 18 2016 pgsql
drwxr-xr-x@ 6 root wheel 204 Oct 21 2014 private
drwxr-xr-x@ 59 root wheel 2006 Aug 2 2017 sbin
-rw-rw-rw- 1 coreyvincent wheel 1309 Feb 5 19:22 sockets.log
lrwxr-xr-x@ 1 root wheel 11 Oct 21 2014 tmp -> private/tmp
drwxr-xr-x 3 coreyvincent wheel 102 Jan 11 2016 user
drwxr-xr-x@ 13 root wheel 442 Apr 17 2015 usr
lrwxr-xr-x@ 1 root wheel 11 Oct 21 2014 var -> private/var
ls -l ~/.ssh
ls: .config.swp: Permission denied
ls: authorized_keys: Permission denied
ls: config: Permission denied
ls: id_dsa: Permission denied
ls: id_dsa.pub: Permission denied
ls: id_rsa: Permission denied
ls: id_rsa.pub: Permission denied
ls: known_hosts: Permission denied
ls: known_hosts.old: Permission denied
sudo ls -l ~/.ssh
Password:
total 72
-rw------- 1 coreyvincent staff 12288 Nov 5 2015 .config.swp
-rw-r--r-- 1 root staff 0 Feb 9 09:40 authorized_keys
-rw------- 1 coreyvincent staff 52 Nov 5 2015 config
-rw------- 1 coreyvincent staff 668 Feb 10 2016 id_dsa
-rw-r--r-- 1 coreyvincent staff 629 Feb 10 2016 id_dsa.pub
-rw------- 1 coreyvincent staff 3247 Jan 23 15:37 id_rsa
-rw-r--r-- 1 coreyvincent staff 748 Jan 23 15:37 id_rsa.pub
-rw------- 1 coreyvincent staff 1222 Nov 22 15:46 known_hosts
-rw-r--r-- 1 coreyvincent staff 0 Nov 22 11:45 known_hosts.old
ls -ld ~/.ssh
drw-r--r-- 11 coreyvincent staff 374 Feb 9 09:40 /Users/coreyvincent/.ssh
Any help would be much appreciated. At this point I can't seem to access anything or connect to Github...
$ ls -ld ~/.ssh
drw-r--r-- 11 coreyvincent staff 374 Feb 9 09:40 /Users/coreyvincent/.ssh
Notice the permissions: drw-r--r--
: it's a directory (d
), it's read-write by the owner (rw-
) and readable by everyone else (r--r--
). However, in order to enter a directory, you need executable permissions. With read/write access, you can view information about the directory, but that's about it.
Add executable permission back. I avoid using the octal notation when I can because it's difficult for me to quickly parse; the symbolic representation (rwx
) by contrast is immediately evident. So,
$ chmod u+x ~/.ssh
is the equivalent of adding executable permission for the user only.
man ssh
recommends the following for the ~/.ssh
directory:
This directory is the default location for all user-specific configuration and authentication information. There is no general requirement to keep the entire contents of this directory secret, but the recommended permissions are read/write/execute for the user, and not accessible by others.
To follow that recommendation, I'd recommend
$ chmod go-r ~/.ssh
since you currently have group (g
) and other (o
) permissions set to read only (r--
).
Further, ~/.ssh/authorized_keys
is recommended to be rw-------
. Simply use the same steps above with that file. As for the rest of the files, they accurately reflect the guidelines (or, in the case of ~/.ssh/config
, the requirements) in man ssh
.
man ssh
man chmod