我正在尝试configurationSFTP,以便我的用户可以访问他们自己的站点文件夹(使用PSFTP / FileZilla)。 我使用Vagrant,CentOS7,NGINX和.sh文件。 这是我的bootstrap.sh,用于创build我的用户之一。 #Make Group for SFTP sudo groupadd sftpusers #Make Website folder and SFTP Users JS_WWW="/usr/share/nginx/html/jeroensteen" sudo useradd -g sftpusers -d $JS_WWW -s /sbin/nologin -p jeroensteen jeroensteen sudo chown jeroensteen:sftpusers $JS_WWW sudo chown nginx:nginx $JS_WWW #Configure SFTP sudo sed -i "s@/usr/libexec/openssh/sftp-server@internal-sftp@" /etc/ssh/sshd_config sudo echo "Match Group sftpusers" > /etc/ssh/sshd_config sudo echo " […]
我有一个由batch file调用的power-shell-script。 批处理在将执行策略设置为不受限制之后调用该脚本。 目前,脚本只是编写一个日志文件,logging它已经被执行。 现在奇怪的是: 情况1:我已经login,双击batch file,脚本立即执行,日志文件写入正确。 一切都按预期工作。 情况2:我没有login,batch file是由我们的UPS,带有PCNS卡的APC Smart-UPS RT 3000XL(我可以在不同的日志中看到批处理的执行时间)正确执行,但是power-shell-script并不总是立即执行。 相反,我必须等待5或10分钟 我怀疑这是一个安全问题,因为脚本迟早会被执行。 这是批处理: echo Shutdown Script> c:\ PowerChuteNWShutdown \ Start.txt C:\ Windows \ System32 \ WindowsPowerShell \ v1.0 \ powershell.exe -command get-executionpolicy C:\ Windows \ System32 \ WindowsPowerShell \ v1.0 \ powershell.exe – 命令set-executionpolicy不受限制C:\ Windows \ System32 \ WindowsPowerShell \ v1.0 \ […]
我需要改变一群用户的组员身份。 我如何 列出所有用户? 将多个用户更改为nogroup主要组? 将辅助/辅助组添加到多个用户? 基本上我需要将当前在clients组中的所有用户改为nogroup ,并将clients作为辅助组添加到他们。 这可以通过shell来完成,而不需要单独编辑每个用户?
我很less使用PowerShell,但我想使用Set-DnsClientServerAddress 。 直接运行告诉我,我需要导入模块DnsClient。 当我运行Import-Module DnsClient我得到下面的输出。 这是怎么回事? 我当然一直没有搞乱这些Windows文件。 我在Windows 8上运行PS v4。 PS C:\> Import-Module DnsClient VERBOSE: Loading module from path 'C:\windows\system32\WindowsPowerShell\v1.0\Modules\DnsClient\DnsClient.psd1'. VERBOSE: Loading 'TypesToProcess' from path 'C:\windows\system32\WindowsPowerShell\v1.0\Modules\DnsClient\DnsCmdlets.Types.ps1xml'. VERBOSE: Loading 'TypesToProcess' from path 'C:\windows\system32\WindowsPowerShell\v1.0\Modules\DnsClient\DnsConfig.Types.ps1xml'. VERBOSE: Loading 'TypesToProcess' from path 'C:\windows\system32\WindowsPowerShell\v1.0\Modules\DnsClient\DnsClientPSProvider.Types.ps1xml'. VERBOSE: Loading 'FormatsToProcess' from path 'C:\windows\system32\WindowsPowerShell\v1.0\Modules\DnsClient\DnsCmdlets.Format.ps1xml'. VERBOSE: Loading 'FormatsToProcess' from path 'C:\windows\system32\WindowsPowerShell\v1.0\Modules\DnsClient\DnsConfig.Format.ps1xml'. VERBOSE: Loading 'FormatsToProcess' from path […]
当我用密钥login到服务器 ssh -i /home/me/.ssh/id_rsa server 一切都没有问题。 密钥在服务器上被授权。 但是,如果我尝试从一个shell脚本做同样的事情,我得到一个密码请求。 当我尝试使用密钥文件scp时也是如此: scp -i /home/me/.ssh/id_rsa file server: 我也为主机创build了〜/ .ssh / config: Host server hostname server IdentityFile /home/me/.ssh/id_rsa 当我尝试SSH与ssh server我也得到一个密码请求。 密钥文件,sshconfiguration和服务器的authorized_keys具有设置为600的权限。 我能做些什么来解决这个问题? 编辑 sshfs也一样。 sshfs -o IdentityFile=/home/me/.ssh/id_rsa server:/directory mountpoint 从cli工作正常。 当它在一个shell脚本中时,我得到一个密码请求。
我正在处理特定任务的自动shell脚本。 在执行任务步骤之前,我想validation通过web服务调用提供给客户的许可证密钥。 请帮助我制作这两个文件(shell脚本和许可证文件)的包(.deb或任何其他),以便最终用户使用简单的命令自动运行。 我提供了示例许可证文件的shell脚本的初始部分 部分shell脚本: #/bin/sh function pause(){ read -p "$*" } file="./license.properties" url="webserviceurl" if [ -f "$file" ] then echo "$file found." . $file echo "sourcing of file is done" echo $productName" "$productVersion "license information" echo "Name of customer =" $customerName echo "license key of customer =" $licenseId else echo "license properties file not […]
为了允许我公司的NOC用户通过NISpipe理用户,我创build了以下脚本: #!/bin/bash # This script will simplicate NIS user management. # You will not be able to change password or delete users peeradmin and root through this script. # Written by Itai Ganot 2014. # Edit only this variable: PROTECTEDUSERS="peeradmin root" # Separate values with spaces. # Variables USER=$1 GREP="/bin/grep" PASSWDFILE="/etc/passwd" YPPASSWD="/usr/bin/yppasswd" USERDEL="/usr/sbin/userdel" USERADD="/usr/sbin/useradd" PASSWD="/usr/bin/passwd" […]
我试图创build一个脚本,当收到特定的文件解压缩它看起来通过解压缩的文件,并删除整个内容,除了两个或三个特定的文件夹及其内容。 然后重新解压缩。 我在压缩,解压缩和删除工作的地方,但是当执行删除时,它会查看所有内容,而不仅仅是顶层的文件夹。 有什么build议么? 我的脚本到目前为止: $filesToZip="c:\temp\powertest\*" $zipfilename = "c:\temp\ziptest.zip" $originalzipfile = "c:\temp\powertest.zip" $extractionlocation = "c:\temp\" function Expand-ZIPFile($file, $destination) { $shell = new-object -com shell.application $zip = $shell.NameSpace($file) foreach($item in $zip.items()) { $shell.Namespace($destination).copyhere($item) } } Expand-ZIPFile –File $originalzipfile –Destination $extractionlocation # replace "New folder" and "New Text Document.txt" with folders and documents you dont want deleted […]
我已经创build了一个发送邮件脚本,可以在我的几个客户端服务器上运行。 邮件在几台服务器上正确发送,但是在一些服务器上,我们收到的格式并不是我们所期望的。 什么可能是错误的服务器的问题,以及如何纠正,使其在所有的服务器上正常工作? 邮件脚本 msg=$toaddr toaddr=$rtnaddr rtnaddr=$ccaddr echo "$msg" | mail -s "$subj" -c $ccaddr "$toaddr" — -f "$rtnaddr" 在这台服务器上正常工作 send_notification "Test" "this is test1" [email protected] noreply@returnaddress [email protected] email toaddress and cc with return address [xxxx1]$ uname -a Linux xxxx1 2.6.39-300.26.1.el5uek #1 SMP Thu Jan 3 18:31:38 PST 2013 x86_64 x86_64 x86_64 GNU/Linux [xxxx1]$ rpm […]
我正在编写一个bash脚本,遇到了一个问题。 我使用普通的if / fi语句来推动我所知道的,并尝试使用它们来设置与拾取操作系统版本相关的variables,如RH 7,Debian 7,Ubuntu等。我遇到的问题是它只是不像我想的那样工作。 我用手运行每个部分,它工作得很好,但是当我把所有东西放在一个脚本中,什么都没有。 有一个更好的方法吗? 先谢谢你 value1=$(cat /etc/redhat-release | awk '{ print $4 }' | cut -c 1) value2=$(cat /etc/redhat-release | awk '{ print $3 }' | cut -c 1) value3=$(lsb_release -sr) value4=$(cat /etc/debian_version) if [[ $value1 -eq 7 ]] && [[ -e /etc/redhat-release ]]; then OS=RedHat VER=RH7 elif [[ $value2 -eq […]