OS X: 实用脚本程序(bash scripts)系列-13

最后更新于:2022-04-01 10:56:58

在远程电脑上启动ssh并端口在3211 把下面的脚本保存,并在目标机运行后,在本机输入ssh user@targetmachine -p 3211就可以了 ~~~ #!/bin/bash if ( ! "$USER = "root" ); then echo "run it as root" exit 1 fi echo "<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Disabled</key> <false/> <key>Label</key> <string>local.sshd</string> <key>Program</key> <string>/usr/libexec/sshd-keygen-wrapper</string> <key>ProgramArguments</key> <array> <string>/usr/sbin/sshd</string> <string>-i</string> </array> <key>Sockets</key> <dict> <key>Listeners</key> <dict> <key>SockServiceName</key> <string>avsecuremgmt</string> </dict> </dict> <key>inetdCompatibility</key> <dict> <key>Wait</key> <false/> </dict> <key>StandardErrorPath</key> <string>/dev/null</string> <key>SHAuthorizationRight</key> <string>system.preferences</string> </dict> </plist> " > /Library/LaunchDaemons/ssh-3211.plist launchctl load /Library/LaunchDaemons/ssh-3211.plist exit 0 ~~~
';