我尝试删除我的私钥文件的所有权限,以便只有我的所有者有权访问它,但它带来了此错误
chmod: prac1: new permissions are ----w--w-, not ---------
请问我该如何解决这个错误,因为如果不解决这个错误,我就无法将我的私钥文件设为私有,并且无法登录我的服务器。有人请帮忙谢谢
这是我使用的命令它已经解决了谢谢它在这里解决了:https://askubuntu.com/questions/1317541/why-is-chmod-rwx-not-removing-all-the-permissions-on-my-private-key-file-the-a 太感谢了!
abayomi@AbayomiUsman:~/.ssh$ chmod -rwx prac1*
chmod: prac1.pub: new permissions are ----w--w-, not ---------
abayomi@AbayomiUsman:~/.ssh$ ll | grep prac1*
abayomi@AbayomiUsman:~/.ssh$ chmod u+r,go-rwx prac1
abayomi@AbayomiUsman:~/.ssh$ ll | grep prac1
-r-xr-xr-x 1 abayomi abayomi 2655 Feb 18 15:55 prac1*
-rwxrwxrwx 1 abayomi abayomi 574 Feb 18 15:55 prac1.pub*
abayomi@AbayomiUsman:~/.ssh$ chown abayomi prac1
abayomi@AbayomiUsman:~/.ssh$ ll | grep prac1
-r-xr-xr-x 1 abayomi abayomi 2655 Feb 18 15:55 prac1*
-rwxrwxrwx 1 abayomi abayomi 574 Feb 18 15:55 prac1.pub*
abayomi@AbayomiUsman:~/.ssh$ chmod 600 prac1
abayomi@AbayomiUsman:~/.ssh$ ll | grep prac1
-rwxrwxrwx 1 abayomi abayomi 2655 Feb 18 15:55 prac1*
-rwxrwxrwx 1 abayomi abayomi 574 Feb 18 15:55 prac1.pub*
答案1
文件只有一个所有者。您可以使用 来设置所有者chown <user> <file>
。
如果您的文件如下所示,这是权限
-rw-r--r-- abayomi abayomi private.key
|| || || | | |
|| || || | | +---- filename
|| || || | +------------------ owning group
|| || || +------------------------------ owning user
|| || |+------------------------------------ others cannot write
|| || +------------------------------------- others can read
|| |+--------------------------------------- owning group cannot write
|| +---------------------------------------- owning group can read
|+------------------------------------------ owning user can write
+------------------------------------------- owning user can read
我想你想要的chmod 600 private.key
这会给你:
-rw------- abayomi abayomi private.key
|| || || | | |
|| || || | | +---- filename
|| || || | +------------------ owning group
|| || || +------------------------------ owning user
|| || |+------------------------------------ others cannot write
|| || +------------------------------------- others cannot read
|| |+--------------------------------------- owning group cannot write
|| +---------------------------------------- owning group cannot read
|+------------------------------------------ owning user can write
+------------------------------------------- owning user can read
600
是一个三位八进制数,其中:
600 6 = 110
||| |||
||+--- other ||+--- execute permission
|+---- group |+---- write permission
+----- user +----- read permission