Mac iTerm 命令权限被拒绝
Mac iTerm commands permission denied
今天我启动了我的 iTerm
,但我在 terminal
中的大部分命令都被拒绝了。
例如,如果我 运行 pbcopy < ~/.ssh/id_rsa.pub
我得到输出 permission denied: /Users/coreyvincent/.ssh/id_rsa.pub
当我尝试通过 ssh 进入我的 Web 应用程序时,我也得到了 permission denied (public key)
,这是我发现我的命令不起作用的第一个实例。
不确定是什么原因造成的,也不知道如何解决。我已经尝试重新添加我的 public 密钥 (ssh-keygen),并且我已经尝试了几个 chmod
命令,但我真的不知道我在那里做什么。
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
如有任何帮助,我们将不胜感激。此时我似乎无法访问任何内容或连接到 Github...
问题
$ ls -ld ~/.ssh
drw-r--r-- 11 coreyvincent staff 374 Feb 9 09:40 /Users/coreyvincent/.ssh
注意权限:drw-r--r--
:它是一个目录(d
),所有者可读写(rw-
),其他人可读(r--r--
).但是,为了进入目录,您需要可执行权限。使用 read/write 访问权限,您可以查看有关目录的信息,但仅此而已。
解决方案
重新添加可执行权限。我尽可能避免使用八进制表示法,因为我很难快速解析;相比之下,符号表示 (rwx
) 立即显而易见。所以,
$ chmod u+x ~/.ssh
相当于只为用户增加可执行权限
其他信息
man ssh
推荐 ~/.ssh
目录如下:
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.
要遵循该建议,我建议
$ chmod go-r ~/.ssh
因为您当前将群组 (g
) 和其他 (o
) 权限设置为只读 (r--
)。
另外,~/.ssh/authorized_keys
推荐为rw-------
。只需对该文件使用上述相同的步骤。至于其余文件,它们准确地反映了 man ssh
.
中的指南(或者,在 ~/.ssh/config
的情况下,要求)
进一步阅读
man ssh
man chmod
今天我启动了我的 iTerm
,但我在 terminal
中的大部分命令都被拒绝了。
例如,如果我 运行 pbcopy < ~/.ssh/id_rsa.pub
我得到输出 permission denied: /Users/coreyvincent/.ssh/id_rsa.pub
当我尝试通过 ssh 进入我的 Web 应用程序时,我也得到了 permission denied (public key)
,这是我发现我的命令不起作用的第一个实例。
不确定是什么原因造成的,也不知道如何解决。我已经尝试重新添加我的 public 密钥 (ssh-keygen),并且我已经尝试了几个 chmod
命令,但我真的不知道我在那里做什么。
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
如有任何帮助,我们将不胜感激。此时我似乎无法访问任何内容或连接到 Github...
问题
$ ls -ld ~/.ssh
drw-r--r-- 11 coreyvincent staff 374 Feb 9 09:40 /Users/coreyvincent/.ssh
注意权限:drw-r--r--
:它是一个目录(d
),所有者可读写(rw-
),其他人可读(r--r--
).但是,为了进入目录,您需要可执行权限。使用 read/write 访问权限,您可以查看有关目录的信息,但仅此而已。
解决方案
重新添加可执行权限。我尽可能避免使用八进制表示法,因为我很难快速解析;相比之下,符号表示 (rwx
) 立即显而易见。所以,
$ chmod u+x ~/.ssh
相当于只为用户增加可执行权限
其他信息
man ssh
推荐 ~/.ssh
目录如下:
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.
要遵循该建议,我建议
$ chmod go-r ~/.ssh
因为您当前将群组 (g
) 和其他 (o
) 权限设置为只读 (r--
)。
另外,~/.ssh/authorized_keys
推荐为rw-------
。只需对该文件使用上述相同的步骤。至于其余文件,它们准确地反映了 man ssh
.
~/.ssh/config
的情况下,要求)
进一步阅读
man ssh
man chmod