mobaxterm的local terminal中的ssh-copy-id报错的问题

下了个 mobaxterm,确实挺好用,不过使用软件自带的local terminal中的ssh-copy-id命令,配置免密登陆linux的时候出现了问题,

ssh-copy-id -i public_key.pub [email protected]

/bin/ssh-copy-id: ERROR: failed to open ID file './public_key': No such file or directory

换了一个版本还是这样,于是自己找到了ssh-copy-id这个命令的代码,在我的文档下的MobaXterm\slash\bin
目录下的ssh-copy-id,备份原文件
找到如下代码段

# check that the files are readable
  for f in $PUB_ID_FILE $PRIV_ID_FILE ; do
    ErrMSG=$( { : < $f ; } 2>&1 ) || {
      printf "\n%s: ERROR: failed to open ID file '%s': %s\n\n" "$0" "$f" "$(printf "%s\n" "$ErrMSG" | sed -e 's/.*: *//')"
      exit 1
    }
  done

注释掉,这个for循环

# check that the files are readable
#  for f in $PUB_ID_FILE $PRIV_ID_FILE ; do
#    ErrMSG=$( { : < $f ; } 2>&1 ) || {
#      printf "\n%s: ERROR: failed to open ID file '%s': %s\n\n" "$0" "$f" "$(printf "%s\n" "$ErrMSG" | sed -e 's/.*: *//')"
#      exit 1
#    }
#  done

再试试

$ ssh-copy-id -i public_key.pub [email protected]
/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/bin/ssh-copy-id: INFO: 9 key(s) remain to be installed -- if you are prompted now it is to install the new keys
stty: standard input: Inappropriate ioctl for device

Number of key(s) added: 9

Now try logging into the machine, with:   "ssh '[email protected]'"
and check to make sure that only the key(s) you wanted were added.

问题解决

另外,我想问问,这代码里面的
{ : < $f ; }
是什么意思,谁给解释解释?

发布了3 篇原创文章 · 获赞 0 · 访问量 787

猜你喜欢

转载自blog.csdn.net/liunan7080/article/details/101630784