dhruvhadoop1@hadoopmaster:~$ cat /home/hadoopuser/.ssh/id_rsa.pub >> /home/hadoopuser/.ssh/authorized_keys
bash: /home/hadoopuser/.ssh/authorized_keys: No such file or directory
dhruvhadoop1@hadoopmaster:~$ cat /home/hadoopuser/.ssh/id_rsa.pub >> /home/hadoopuser/ .ssh/authorized_keys
bash: /home/hadoopuser/: Is a directory
dhruvhadoop1@hadoopmaster:~$ cat /home/hadoopuser/.ssh/id_rsa.pub >> /home/hadoopuser/ .ssh/authorized_keys/
bash: /home/hadoopuser/: Is a directory
dhruvhadoop1@hadoopmaster:~$ cat /home/hadoopuser/.ssh/id_rsa.pub >> /home/hadoopuser/.ssh/authorized_keys
bash: /home/hadoopuser/.ssh/authorized_keys: No such file or directory
dhruvhadoop1@hadoopmaster:~$
答案1
該.ssh
目錄及其檔案具有嚴格的存取權限:檔案只能由所有者(或根)讀取/寫入。如果您不是hadoopuser
,那麼您必須:
sudo sh -c 'cat /home/hadoopuser/.ssh/id_rsa.pub >> /home/hadoopuser/.ssh/authorized_keys'
該錯誤訊息有點誤導。您正在嘗試追加,因此 shell 必須檢查authorized_keys 檔案是否存在。您沒有 .ssh 目錄的讀取權限,因此 shell 無法完成該檢查。
答案2
這.ssh資料夾不存在,因為您尚未建立任何金鑰。您必須先像這樣建立密鑰:
ssh-keygen
並輸入 shell 提出的任何問題。之後你有.ssh您家中的資料夾。
答案3
您發布的大多數錯誤訊息是因為您沒有使用正確的路徑,因為您在各個位置添加了空格或指定了目錄而不是檔案。
唯一真正相關的錯誤訊息是
/home/hadoopuser/.ssh/authorized_keys:沒有這樣的檔案或目錄
您無法附加不存在的文件,因此要么複製該文件(首選方法)
cp /home/hadoopuser/.ssh/id_rsa.pub /home/hadoopuser/.ssh/authorized_keys
或使用單一建立文件>
cat /home/hadoopuser/.ssh/id_rsa.pub > /home/hadoopuser/.ssh/authorized_keys