Skip to content

Conversation

@lixiang2017
Copy link

@lixiang2017 lixiang2017 commented Sep 22, 2021

  1. I met this error
    INFO:paramiko.transport:Authentication (password) successful!
    bash: /root/.ssh/authorized_keys: 权限不够
    ERROR:root:Encountered a bad command exit code!
    Command: "sudo -S -p '[sudo] password: ' echo 'ssh-rsa a_very_long_string root@s1' >> /root/.ssh/authorized_keys"
    Exit code: 1

  2. when I excute the follow command manually, it passed.
    sudo -S -p '[sudo] password: ' bash -c "echo 'ssh-rsa a_very_long_string root@s1' >> /root/.ssh/authorized_keys "

  3. the reason is that >> /root/.ssh/authorized_keys doesn't have sudo priviledge.
    So we need bash -c "a_long_command" to wrap them up.

1. I met this error
INFO:paramiko.transport:Authentication (password) successful!
bash: /root/.ssh/authorized_keys: 权限不够
ERROR:root:Encountered a bad command exit code!
Command: "sudo -S -p '[sudo] password: ' echo 'ssh-rsa  a_very_long_string  root@s1' >> /root/.ssh/authorized_keys"
Exit code: 1

2. when I excute the follow command manually, it passed.
sudo -S -p '[sudo] password: ' bash -c "echo 'ssh-rsa  a_very_long_string  root@s1' >> /root/.ssh/authorized_keys "

3. the reason is that `` >> /root/.ssh/authorized_keys`` doesn't have sudo priveledge.
So we need  ``bash -c "a_long_command" `` to wrap them up.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant