Why do I occasionally get this error when running ssh-keyscan
inside of sudo
:
$ /usr/bin/sudo /usr/bin/bash -c '/usr/bin/ssh-keyscan 10.1.2.11 >> /root/.ssh/known_hosts'
$ echo $?
1
$ /usr/bin/sudo /usr/bin/bash -c '/usr/bin/ssh-keyscan 10.1.2.11 >> /root/.ssh/known_hosts'
# 10.1.2.11:22 SSH-2.0-OpenSSH_8.0
# 10.1.2.11:22 SSH-2.0-OpenSSH_8.0
# 10.1.2.11:22 SSH-2.0-OpenSSH_8.0
$ sudo journalctl -r
...
Nov 06 19:20:28 c1-n2.local sudo[5198]: pam_unix(sudo:session): session opened for user root by vagrant(uid=0)
Nov 06 19:20:28 c1-n2.local sudo[5198]: pam_systemd(sudo:session): Cannot create session: Already running in a session or user slice
Nov 06 19:20:28 c1-n2.local sudo[5198]: vagrant : TTY=pts/0 ; PWD=/home/vagrant ; USER=root ; COMMAND=/bin/journalctl -r
...
I noticed it fails the first try, but then any quite succession after that.
If I wait several minutes, it fails on the first try again.
Here's the version
$ cat /etc/redhat-release
CentOS Linux release 8.2.2004 (Core)
$ cat /etc/os-release
NAME="CentOS Linux"
VERSION="8 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="8"
PLATFORM_ID="platform:el8"
PRETTY_NAME="CentOS Linux 8 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:8"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-8"
CENTOS_MANTISBT_PROJECT_VERSION="8"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="8"