I'm trying to build a private apt repository using reprepro. I managed to get password-less SSH login after creating a SSH key chain. I can successful login to the repository if I SSH into it.

On the client machine I added the repository in the apt sources list like:

deb ssh://repo@ xenial main

But when I try to use apt-get update, I still need to enter the password otherwise it won't proceed. It only shows:

100% [Connecting to repo@]

Is there a way that apt can use my key get access to the repository without entering a password?


I solved this problem by creating a ssh key as root on the client machine. After that i needed to add this public key to the authorized_keys on the ubuntu server machine. Now I can make use of the apt repository using ssh with the keys without entering a password.


You need to add the command to /etc/sudoers. Have a look at this How do I run specific sudo commands without a password?

Another option is to ssh passwordless with the root user but, it's generally considered a very bad idea. How to setup passwordless SSH access for root user

In your repo, become root with sudo su and then run this command:

echo "%sudo ALL=NOPASSWD: /usr/bin/apt-get" >> /etc/sudoers

This will allow any user to run apt-get without password. This command is used to upgrade, but it can also be used to install/uninstall packages... be careful. I think it would be better to use the password or enable automatic updates in the server.

  • Thanks for your answer, unfortunately I still can't update without entering the password of the ssh repo. I tried this: sudo visudo guy guy-rcs=(root)NOPASSWD:/usr/bin/apt-get update,/usr/bin/apt-get upgrade – Guy Liqui Lung Oct 6 '16 at 9:23
  • Undo your changes and check my edit and see if it helps. You don't need to specify update and upgrade at the end, the apt-get command will run passwordless with any argument. – Katu Oct 6 '16 at 9:32
  • Tried your new command on the client side and on the server side. I can't run apt-get without sudo. I hope you can help me. – Guy Liqui Lung Oct 6 '16 at 9:46
  • You should be able to run apt-get with sudo but without a password. It worked for me. Check all the steps carefully and I hope you can solve it. – Katu Oct 6 '16 at 10:12
  • Tried it out this is when I try to apt-get update after your instructions 'guy@guy-rcs:~$ apt-get update E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied) E: Unable to lock directory /var/lib/apt/lists/ E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied) E: Unable to lock the administration directory (/var/lib/dpkg/), are you root? ' – Guy Liqui Lung Oct 7 '16 at 7:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.