# gpg: cannot open `/dev/tty': No such device or address

## charles17

Could someone help with this?  I came across from the Pulling validated Gentoo ebuild tree snapshots of the handbook.

When I do  *Quote:*   

> $ su -c "gpg --homedir /var/lib/gentoo/gkeys/keyrings/gentoo/release --edit-key 0xF6CD6C97 check"

 

it tells me  *Quote:*   

> Password: 
> 
> gpg: WARNING: unsafe permissions on homedir `/var/lib/gentoo/gkeys/keyrings/gentoo/release'
> 
> gpg (GnuPG) 2.0.28; Copyright (C) 2015 Free Software Foundation, Inc.
> ...

 

Searching the internet for this message I could not find a solution.  

Any idea? What's the problem with gnupg and /dev/tty?

----------

## Princess Nell

The warning indicates the permissions of the "homedir" are wrong - they probably need to be 0700.

edit-key is by nature an interactive command, but you're not running interactively. Try --no-tty.

----------

## charles17

Thanks Princess Nell for your answer.  

Changed the permission to 700. But when I try with --no-tty  *Quote:*   

> su -c "gpg --no-tty --homedir /var/lib/gentoo/gkeys/keyrings/gentoo/release --edit-key 0xF6CD6C97 check"

 

It would end up with *Quote:*   

> Password: 
> 
> gpg (GnuPG) 2.0.28; Copyright (C) 2015 Free Software Foundation, Inc.
> 
> This is free software: you are free to change and redistribute it.
> ...

 

That also doesn't look very promising.

But when I try it as root it works  *Quote:*   

> root #  gpg --homedir /var/lib/gentoo/gkeys/keyrings/gentoo/release/ --edit-key F6CD6C97 trust
> 
> gpg: WARNING: unsafe ownership on homedir `/var/lib/gentoo/gkeys/keyrings/gentoo/release/'
> 
> gpg (GnuPG) 2.0.28; Copyright (C) 2015 Free Software Foundation, Inc.
> ...

 

Why can't I do that from normal user with su -c?

----------

## Princess Nell

Use --batch, not --no-tty. And update those permissions  :Smile: 

----------

## charles17

 *Princess Nell wrote:*   

> Use --batch, not --no-tty. And update those permissions 

 

Works for  *Quote:*   

> $ su -c "gpg --batch --homedir /var/lib/gentoo/gkeys/keyrings/gentoo/release --edit-key 0xF6CD6C97 check"

 

But not for  *Quote:*   

> $ su -c "gpg --batch --homedir /var/lib/gentoo/gkeys/keyrings/gentoo/release --edit-key 0xF6CD6C97 trust"
> 
> ...
> 
> ...
> ...

 

Seems that su -c "gpg ......." is not so recommended

----------

## Princess Nell

The second command is incomplete and waiting for input, so not a candidate for --batch in this form.

----------

