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

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

ssh-copy-id -i public_key.pub root@192.168.71.129

/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 root@192.168.71.129
/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 'liunan@192.168.71.129'"
and check to make sure that only the key(s) you wanted were added.

问题解决

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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值