AppleScript C Perl Shell Xcode Other

SSH double login to your server

Post Reply
coding / applescript     Views: 3153Prev .. Next
SSH double login to your serverPosted: Monday, June 21, 2010 [22:42:31] - 1
rootPosted by:rootMember Since:
June 16 2010
Posts: 357
This script will do a login to your server and then "su". Very handy to have if you are a server admin and do not want to search for your passwords every time you have to do an administrative tasks.

Why double login? - it was never advisable to login directly as "root", therefore it's best to login first to your regular user account and then "su" to your root account. "root" login should be disabled on your server.

It will work best if you save this AppleScript as a "run only" application in your password protected image file. This way you have to remember only one password.

View Codetell application "System Events"
if not (exists process "Terminal") then
set aDone to 0
set wCounter to 0
tell application "Terminal"
activate
delay 2
make new document
end tell
else
delay 2
set wCounter to 1
tell application "Terminal"
activate
delay 2
end tell
end if
end tell

delay 2

tell application "System Events"
tell process "Terminal"
keystroke "n" using {command down}
delay 3
keystroke "k" using {command down}
delay 1
-- this is your regular user user_name
keystroke "ssh IP-Address -l user_name"
delay 2
keystroke return
delay 5
keystroke "k" using {command down}
delay 1
keystroke "a" using {command down}
delay 1
keystroke "c" using {command down}
delay 1
set screenData to (the clipboard) as text
if screenData contains "password" then
-- this is your regular user_name password
keystroke "your_password"
delay 2
keystroke return
delay 5
end if
delay 3
keystroke "k" using {command down}
delay 1
keystroke "a" using {command down}
delay 1
keystroke "c" using {command down}
delay 1
set screenData to (the clipboard) as text
-- replace user_name with your account username
if screenData contains "user_name@" then
keystroke "su"
delay 1
keystroke return
delay 3
keystroke "your_root_password_here"
delay 1
keystroke return
delay 2
end if
end tell
end tell
delay 2

Just run the application and you'll be logged.There's no place like ~
coding / applescriptPrev .. Next
 
Post Reply
Home - Coding: AppleScript C Perl Shell Xcode Other
Our Telegram Group