Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ssh-copy-id fails, cannot create /dev/null permission denied, EOF not found #1804

Closed
Soundtoxin opened this issue Oct 30, 2020 · 5 comments
Closed

Comments

@Soundtoxin
Copy link

Problem description

I'm trying to get my usual ssh stuff set up, but I can't seem to copy my newly created key to new machines.

/data/data/com.termux/files/usr/bin/ssh-copy-id: 254: cannot create /dev/null': Permission denied
/data/data/com.termux/files/usr/bin/ssh-copy-id: 260: EOF: not found

Steps to reproduce

  1. ssh-keygen -t ed25519
  2. take all defaults
  3. ssh-copy-id user@host

Expected behavior

Usually this copies the key normally, no errors, then I can ssh into that machine without a password.

Additional information

  • Termux application version: 0.102
  • Android OS version: 9 (LineageOS 16)
  • Device model: OnePlus 5 (cheeseburger)
@ghost
Copy link

ghost commented Oct 30, 2020

cannot create /dev/null': Permission denied

If /dev/null is not available or restricted on your device, we can't help unfortunately. Access restriction to /dev/null looks quite weird, especially on Lineage OS ROMs. Also, if /dev/null is restricted, many other packages will not work too.

I'm using Lineage OS as well, but never observed such issue.

This is not subject for fixing on Termux side because this is ROM bug.


What commands echo foo > /dev/null and stat /dev/null show?

@Soundtoxin
Copy link
Author

Yeah, only experienced this on this device out of many, so ROM bug makes sense.

$ echo foo > /dev/null
$ stat /dev/null
  File: /dev/null
  Size: 0               Blocks: 0          IO Block: 4096   character special file
Device: 10h/16d Inode: 17387       Links: 1     Device type: 1,3
Access: (0666/crw-rw-rw-)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 1973-05-04 08:35:24.976666813 -0500
Modify: 1973-05-04 08:35:24.976666813 -0500
Change: 1973-05-04 08:35:33.790001025 -0500
 Birth: -
$

@ghost
Copy link

ghost commented Oct 30, 2020

Hm... from your tests /dev/null appears to be available and accessible as it should.

Could you try to re-exec ssh-copy-id but in way like

bash -x $PREFIX/bin/ssh-copy-id user@host

and post trace here?

@Soundtoxin
Copy link
Author

$ bash -x $PREFIX/bin/ssh-copy-id brad@anpan
+ false '^' printf '%s: WARNING: ancient shell, hunting for a more modern one... ' /data/data/com.termux/files/usr/bin/ssh-copy-id
++ grep -v -- '-cert.pub$'
++ ls -t /data/data/com.termux/files/home/.ssh/id_ed25519.pub
++ head -n 1
+ DEFAULT_PUB_ID_FILE=/data/data/com.termux/files/home/.ssh/id_ed25519.pub
+ '[' -n '' ']'
+ getopts 'i:o:p:F:fnh?' OPT
+ shift 0
+ '[' 1 = 0 ']'
+ '[' 1 '!=' 1 ']'
+ USER_HOST=brad@anpan
++ quote brad@anpan
++ printf '%s\n' brad@anpan
++ sed -e 's/'\''/'\''\\'\'''\''/g'
+ SSH_OPTS=''\''brad@anpan'\'''
+ eval set -- ''\''brad@anpan'\'''
++ set -- brad@anpan
++ eval
+ '[' -z '' ']'
+ '[' -r /data/data/com.termux/files/home/.ssh/id_ed25519.pub ']'
+ use_id_file /data/data/com.termux/files/home/.ssh/id_ed25519.pub
+ local L_ID_FILE=/data/data/com.termux/files/home/.ssh/id_ed25519.pub
+ '[' -z /data/data/com.termux/files/home/.ssh/id_ed25519.pub ']'
+ expr /data/data/com.termux/files/home/.ssh/id_ed25519.pub : '.*\.pub$'
+ PUB_ID_FILE=/data/data/com.termux/files/home/.ssh/id_ed25519.pub
+ '[' '' ']'
++ dirname /data/data/com.termux/files/home/.ssh/id_ed25519.pub
++ basename /data/data/com.termux/files/home/.ssh/id_ed25519.pub .pub
+ PRIV_ID_FILE=/data/data/com.termux/files/home/.ssh/id_ed25519
+ for f in "$PUB_ID_FILE" ${PRIV_ID_FILE:+"$PRIV_ID_FILE"}
+ ErrMSG='++ :'
+ for f in "$PUB_ID_FILE" ${PRIV_ID_FILE:+"$PRIV_ID_FILE"}
+ ErrMSG='++ :'
+ printf '%s: INFO: Source of key(s) to be installed: "%s"\n' /data/data/com.termux/files/usr/bin/ssh-copy-id /data/data/com.termux/files/home/.ssh/id_ed25519.pub
/data/data/com.termux/files/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/data/data/com.termux/files/home/.ssh/id_ed25519.pub"
+ GET_ID='cat "/data/data/com.termux/files/home/.ssh/id_ed25519.pub"'
++ eval cat '"/data/data/com.termux/files/home/.ssh/id_ed25519.pub"'
+++ cat /data/data/com.termux/files/home/.ssh/id_ed25519.pub
+ '[' -z 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID3YetiW+S/aWXVxEHVrE+bWxNHcqfL5M/SSwSWN/ph1 u0_a170@localhost' ']'
++ ssh -v -o PreferredAuthentications=, -o ControlPath=none brad@anpan
++ sed -ne 's/.*remote software version //p'
+ REMOTE_VERSION=$'OpenSSH_8.3\r'
+ case "$REMOTE_VERSION" in
+ populate_new_ids 0
+ local L_SUCCESS=0
+ '[' '' ']'
+ eval set -- ''\''brad@anpan'\'''
++ set -- brad@anpan
+ umask 0177
+ local L_TMP_ID_FILE
++ mktemp /data/data/com.termux/files/home/.ssh/ssh-copy-id_id.XXXXXXXXXX
+ L_TMP_ID_FILE=/data/data/com.termux/files/home/.ssh/ssh-copy-id_id.8zu4UyCyMF
+ test 0 -ne 0
+ test x/data/data/com.termux/files/home/.ssh/ssh-copy-id_id.8zu4UyCyMF = x
+ local 'L_CLEANUP=rm -f "/data/data/com.termux/files/home/.ssh/ssh-copy-id_id.8zu4UyCyMF" "/data/data/com.termux/files/home/.ssh/ssh-copy-id_id.8zu4UyCyMF.stderr"'
+ trap 'rm -f "/data/data/com.termux/files/home/.ssh/ssh-copy-id_id.8zu4UyCyMF" "/data/data/com.termux/files/home/.ssh/ssh-copy-id_id.8zu4UyCyMF.stderr"' EXIT TERM INT QUIT
+ printf '%s: INFO: attempting to log in with the new key(s), to filter out any that are already installed\n' /data/data/com.termux/files/usr/bin/ssh-copy-id
/data/data/com.termux/files/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
++ eval cat '"/data/data/com.termux/files/home/.ssh/id_ed25519.pub"'
+++ cat /data/data/com.termux/files/home/.ssh/id_ed25519.pub
++ read -r ID
++ printf '%s\n' 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID3YetiW+S/aWXVxEHVrE+bWxNHcqfL5M/SSwSWN/ph1 u0_a170@localhost'
++ ssh -i /data/data/com.termux/files/home/.ssh/id_ed25519 -o ControlPath=none -o LogLevel=INFO -o PreferredAuthentications=publickey -o IdentitiesOnly=yes brad@anpan exit
++ '[' 255 = 0 ']'
++ grep 'Permission denied' /data/data/com.termux/files/home/.ssh/ssh-copy-id_id.8zu4UyCyMF.stderr
++ cat /data/data/com.termux/files/home/.ssh/ssh-copy-id_id.8zu4UyCyMF
++ read -r ID
++ '[' '' ']'
+ NEW_IDS='ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID3YetiW+S/aWXVxEHVrE+bWxNHcqfL5M/SSwSWN/ph1 u0_a170@localhost'
+ eval 'rm -f "/data/data/com.termux/files/home/.ssh/ssh-copy-id_id.8zu4UyCyMF" "/data/data/com.termux/files/home/.ssh/ssh-copy-id_id.8zu4UyCyMF.stderr"'
++ rm -f /data/data/com.termux/files/home/.ssh/ssh-copy-id_id.8zu4UyCyMF /data/data/com.termux/files/home/.ssh/ssh-copy-id_id.8zu4UyCyMF.stderr
+ trap - EXIT TERM INT QUIT
+ expr 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID3YetiW+S/aWXVxEHVrE+bWxNHcqfL5M/SSwSWN/ph1 u0_a170@localhost' : '^ERROR: '
+ '[' -z 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID3YetiW+S/aWXVxEHVrE+bWxNHcqfL5M/SSwSWN/ph1 u0_a170@localhost' ']'
++ printf '%s\n' 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID3YetiW+S/aWXVxEHVrE+bWxNHcqfL5M/SSwSWN/ph1 u0_a170@localhost'
++ wc -l
+ printf '%s: INFO: %d key(s) remain to be installed -- if you are prompted now it is to install the new keys\n' /data/data/com.termux/files/usr/bin/ssh-copy-id 1
/data/data/com.termux/files/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
+ '[' '' ']'
+ printf '%s\n' 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID3YetiW+S/aWXVxEHVrE+bWxNHcqfL5M/SSwSWN/ph1 u0_a170@localhost'
++ installkeys_sh
++ local AUTH_KEY_FILE=.ssh/authorized_keys
/data/data/com.termux/files/usr/bin/ssh-copy-id: line 251: warning: here-document at line 251 delimited by end-of-file (wanted `EOF')
/data/data/com.termux/files/usr/bin/ssh-copy-id: line 250: warning: here-document at line 250 delimited by end-of-file (wanted `EOF')
+++ tr '\t\n' ' '
++ INSTALLKEYS_SH=
++ cd
++ umask 077
+++ dirname .ssh/authorized_keys
++ mkdir -p .ssh
++ '[' -z '`tail' -1c .ssh/authorized_keys ']'
/data/data/com.termux/files/usr/bin/ssh-copy-id: line 254: /dev/null`: Permission denied
++ echo
++ cat
++ type restorecon
++ EOF
/data/data/com.termux/files/usr/bin/ssh-copy-id: line 260: EOF: command not found
++ printf 'exec sh -c '\''%s'\''' ''
+ ssh brad@anpan 'exec sh -c '\'''\'''

ghost pushed a commit to termux/termux-packages that referenced this issue Oct 30, 2020
@ghost
Copy link

ghost commented Oct 30, 2020

It seems to be broken. I have managed to get exactly same error.

Copy of ssh-copy-id from Ubuntu 20.04 works without issues, so Termux will use it now instead of what is bundled with OpenSSH sources.

termux/termux-packages@6df03f4

@ghost ghost closed this as completed Oct 30, 2020
Harshiv-Patel pushed a commit to Harshiv-Patel/termux-packages that referenced this issue Aug 15, 2021
@ghost ghost locked and limited conversation to collaborators Oct 17, 2021
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant