簡體   English   中英

當我嘗試使用linux期望ssh遠程計算機時,身份驗證非常慢,為什么?

[英]When I try to use linux expect to ssh remote machine, the authentication is very slow ,why?

我嘗試使用它,但是發現它非常慢。

我的代碼:

#!/usr/bin/expect -f
set hostname [lindex $argv 0]
spawn ssh "xxx\@$hostname"
expect "password: "
send "xxxxx\r"
expect "$ "
send "sudo su admin\r"
expect "assword:\n"
send "xxxxx\r"
expect "$ "
send "cat /tmp/id_rsa.pub >> /home/admin/.ssh/authorized_keys\r"
expect "$ "
send "exit\r"

你有什么建議嗎?

exp_internal 1添加到腳本的頂部,以便您可以查看期望的操作。

我懷疑這是錯誤的: expect "assword:\\n" -我敢打賭實際的密碼提示不以換行符結尾。 嘗試刪除\\n

嘗試

ssh -o GSSAPIAuthentication = no login @ remoteipipaddress

如果成功,則需要編輯/ etc / ssh / ssh_config和/ etc / ssh / sshd_config並尋找GSSAPIAuthentication。 請將值更改為“否”。

它為我工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM