[英]SUDO - iOS FTP - Stuck
I have a script for MobileTerminal in iOS that requires su, is there any way I can add a command to the bash script to login as root without having to type su then the password? 我在iOS中有一个需要su的MobileTerminal脚本,有什么方法可以将命令添加到bash脚本中以root身份登录,而无需键入su和密码?
Cheers, 干杯,
Dec 十二月
在iOS中不允许SUDO和系统功能,因为它们违反了沙箱和安全性。
That's the solution worked for me: 那是我的解决方案:
SSH to your iPhone SSH到您的iPhone
$ssh root@<your iphone ip> Password: alpine //no echo
and run 并运行
iPhone:~ root# visudo
add right after 在之后添加
root ALL=(ALL) ALL
this line (varies of what you want) 这条线(随您想要的而变化)
mobile ALL=(ALL) ALL
sudo
. 现在您可以sudo
。 For editing with visudo
you should use controls like in vi
使用visudo
进行编辑时,应使用vi
控件 After all add to your script hardcoded sudo
call like this 毕竟这样添加到脚本的硬编码sudo
调用
#!/bin/bash sudo -S -p "" echo -n "" <<! alpine ! sudo echo "This line is printed as root"
Now explanation: 现在说明:
-S
allows reading password from <<!\\n ... \\n!
-S
允许从<<!\\n ... \\n!
读取密码 block, it should be printed on a single line 块,它应该打印在一行上 -p ""
suppresses password promt, so the line Password:
is not printed -p ""
禁止输入密码,因此不会显示Password:
echo -n
disallows a newline character in the end echo -n
不允许换行符 So you can sudo
in your script without any password promt. 因此,您可以在脚本中进行sudo
,而无需输入任何密码。 The only thing - in this method password is hardcoded. 唯一的事情-在这种方法中,密码是硬编码的。 But you can try command line arguments like $1 (not tested, just an idea) 但是您可以尝试像$ 1这样的命令行参数(未经测试,只是一个想法)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.