sudo ssh-add -L > /mnt/home/debian/.ssh/authorized_keys -bash: /mnt/home/debian/.ssh/authorized_keys: 只读文件系统
时间: 2024-11-24 20:40:32 浏览: 37
这条命令试图将SSH密钥添加到远程用户的`~/.ssh/authorized_keys`文件中,但是由于`/mnt/home/debian/.ssh/authorized_keys`是在只读文件系统上(通常是像外部USB、CD/DVD这样的临时或受限访问路径),所以会遇到权限问题。
在只读文件系统上执行写操作,如追加(`> ...`)新内容,是被禁止的。这是因为该系统设计成仅允许读取,防止数据被意外篡改或覆盖。
为了解决这个情况,你需要将SSH密钥复制到宿主机的一个可以写入的位置(如`~/tmp`或者其他你有权限的目录),然后从那里将密钥内容手动粘贴到目标位置,或者通过其他方式(如scp、rsync)将整个`.ssh`目录复制过去。完成后再调整权限:
```bash
# 将私钥复制到可写目录
cp ~/.ssh/id_rsa.pub ~/tmp/
# 在宿主机上执行写操作
vim ~/tmp/your_key # 这里替换为你实际的公钥文件名
# 或者使用cat命令直接粘贴
cat ~/tmp/your_key >> /mnt/home/debian/.ssh/authorized_keys
# 到目标机器上设置权限
sudo chown -R debian:debian /mnt/home/debian/.ssh
sudo chmod -R go-rwx /mnt/home/debian/.ssh
# 让SSH服务加载新的密钥
ssh-keygen -A
阅读全文
相关推荐
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![x](https://img-home.csdnimg.cn/images/20250102104920.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)