在脚本中提供用户密码
Giving the user password in a script
我制作了一个允许 ftp login.But 我不知道如何为用户添加密码的脚本
#!/bin/bash
if grep -q "/opt/proftpd.conf"; then
echo " is an ftp user"
HOST='192.168.1.212'
USER=''''
FILE=''''
ftp -n -v $HOST <<END_SCRIPT
quote USER $USER
put $FILE
quit
END_SCRIPT
ls -la /home/
exit 0
else
echo " is not an ftp user"
fi
exit 0
如何为ftp用户添加用户密码?...
这取决于 ftp 版本。
有时版本允许提供用户和密码以及主机名:
ftp://[user[:password]@]host[:port]/path
还有两个 ftp 命令允许传递凭据 (man ftp):
account [passwd]
Supply a supplemental password required by a remote system
for access to resources once a login has been successfully
completed. If no argument is included, the user will be
prompted for an account password in a non-echoing input mode.
user user-name [password] [account]
Identify yourself to the remote FTP server. If the password
is not specified and the server requires it, ftp will prompt
the user for it (after disabling local echo). If an account
field is not specified, and the FTP server requires it, the
user will be prompted for it. If an account field is speci-
fied, an account command will be relayed to the remote server
after the login sequence is completed if the remote server
did not require it for logging in. Unless ftp is invoked
with "auto-login" disabled, this process is done automati-
cally on initial connection to the FTP server.
一个例子:
#!/bin/bash
ftp_host="192.168.1.212"
ftp_user=""
ftp_file=""
read -s -p "Enter password for user ${ftp_user}: " ftp_pass
ftp -n -v ${ftp_host} << EOF
quote USER ${ftp_user}
quote pass ${ftp_pass}
bin
put ${ftp_file}
EOF
我制作了一个允许 ftp login.But 我不知道如何为用户添加密码的脚本
#!/bin/bash
if grep -q "/opt/proftpd.conf"; then
echo " is an ftp user"
HOST='192.168.1.212'
USER=''''
FILE=''''
ftp -n -v $HOST <<END_SCRIPT
quote USER $USER
put $FILE
quit
END_SCRIPT
ls -la /home/
exit 0
else
echo " is not an ftp user"
fi
exit 0
如何为ftp用户添加用户密码?...
这取决于 ftp 版本。 有时版本允许提供用户和密码以及主机名:
ftp://[user[:password]@]host[:port]/path
还有两个 ftp 命令允许传递凭据 (man ftp):
account [passwd]
Supply a supplemental password required by a remote system
for access to resources once a login has been successfully
completed. If no argument is included, the user will be
prompted for an account password in a non-echoing input mode.
user user-name [password] [account]
Identify yourself to the remote FTP server. If the password
is not specified and the server requires it, ftp will prompt
the user for it (after disabling local echo). If an account
field is not specified, and the FTP server requires it, the
user will be prompted for it. If an account field is speci-
fied, an account command will be relayed to the remote server
after the login sequence is completed if the remote server
did not require it for logging in. Unless ftp is invoked
with "auto-login" disabled, this process is done automati-
cally on initial connection to the FTP server.
一个例子:
#!/bin/bash
ftp_host="192.168.1.212"
ftp_user=""
ftp_file=""
read -s -p "Enter password for user ${ftp_user}: " ftp_pass
ftp -n -v ${ftp_host} << EOF
quote USER ${ftp_user}
quote pass ${ftp_pass}
bin
put ${ftp_file}
EOF