gpt4 book ai didi

git - Mac iTerm 命令权限被拒绝

转载 作者:行者123 更新时间:2023-12-02 14:18:31 26 4
gpt4 key购买 nike

今天我启动了我的iTerm我在 terminal 中的大多数命令都被拒绝了权限.

例如,如果我运行 pbcopy < ~/.ssh/id_rsa.pub我得到输出 permission denied: /Users/coreyvincent/.ssh/id_rsa.pub
我也收到了permission denied (public key)当我尝试 ssh 进入我的网络应用程序时,这是我发现我的命令不起作用的第一个实例。

不确定是什么原因造成的或如何解决。我尝试重新添加我的公钥(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--)。但是,为了进入目录,您需要可执行权限。通过读/写访问,您可以查看有关目录的信息,但仅此而已。

解决方案

重新添加可执行权限。我尽可能避免使用八进制表示法,因为我很难快速解析;相比之下,符号表示 ( 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------- .只需对该文件使用上述相同步骤即可。至于其余的文件,它们准确地反射(reflect)了 ~/.ssh/config 中的指导方针(或者,在 man ssh 的情况下,要求)。 .

进一步阅读
  • man ssh
  • man chmod
  • 关于git - Mac iTerm 命令权限被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48710200/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com