mkdir:无法创建目录“.ssh”:ssh-copy-id 时权限被拒绝

mkdir:无法创建目录“.ssh”:ssh-copy-id 时权限被拒绝
┌─╼ [~/Downloads]
└╼ ssh-copy-id -i ~/.ssh/id_ed25519 my_username@server
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/infinity/.ssh/id_ed25519.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
my_username@server's password: 
Could not chdir to home directory /gel/usr/my_username: No such file or directory
sh: line 0: cd: /gel/usr/my_username: No such file or directory
mkdir: cannot create directory ‘.ssh’: Permission denied

我连接到服务器,但无法my_username/gel/usr.有解决方法来解决这个问题吗?我可以在服务器中以某些方式修改 $PATH 来解决这个问题吗?

答案1

如错误行所示,该位置没有主目录

Could not chdir to home directory /gel/usr/my_username: No such file or directory

/home/例如,通常主目录位于/home/username.

您可以/etc/passwd直接编辑文件并输入正确的预先存在的路径,也可以使用命令usermod更改主目录,如下所示:

usermod -d /home/username username

您将需要更改用户名的实例以符合您的情况。

相关内容