2017-01-20 11 views
1

、私は一日-日のssh接続にリンゴスクリプトを使ってssh接続を行う方法は?

を支援するために、簡単なリンゴのスクリプトを開発しています。ここ

tell application "Terminal" 
    set ServerName to "IP" 
    set ServerUserName to "user" 
    set ServerPassword to "password" 
end tell 

例だと、今、私の疑問があります。

私はssh [email protected]をどのようにしてパスワードを送信できますか?

これはなんですか?

do shell script "ssh " & ServerUserName & " @ " & ServerAddress 
dealy 5 
keystroke ServerPassword 

おかげ

+0

公開鍵認証を設定します。パスワードをハードコードしないでください。それは良い習慣ではありません。 – Jakuje

答えて

0

@Jakujeで述べたようにあなたは、ハードコードされたパスワードを使用してはならないが、あなたは、このメソッドを使用することができます。

tell application "Terminal" 
set ServerAddress to "IP" 
set ServerUserName to "user" 
set ServerPassword to "pw" 
end tell 

tell application "Terminal" 
set currentTab to do script ("ssh " & ServerUserName & "@" & ServerAddress & ";") 
delay 5 
do script (ServerPassword) in currentTab 
end tell 

んこのヘルプあなたは?

関連する問題