636

$ sudo apt-get install sshpass $ sshpass -p your_password ssh user@hostname


52

Don't bother with uninstalling or fixing bloatware. Just reimage the computers. In fact it's pretty easy to setup a reference image, sysprep, capture, and deploy it using WDS + MDT. See the aforementioned for various driver packages: trust me you're not the first person to think of this stuff, it's been solved already. Profiles can be transferred with USMT. ...


52

Update - While this answer explains the process and mechanics of PowerShell runspaces and how they can help you multi-thread non-sequential workloads, fellow PowerShell aficionado Warren 'Cookie Monster' F has gone the extra mile and incorporated these same concepts into a single tool called Invoke-Parallel - it does what I describe below, and he has since ...


33

If you are using Ansible 1.4 or later (which I recommend) you can access the remote PATH env variable: - pip: name=psycopg2 virtualenv=/path/to/my/venv environment: PATH: /usr/pgsql-9.3/bin:{{ ansible_env.PATH }} If instead you are interested in the PATH env var of the local client running the Ansible scripts (instead of the targeted server), then ...


21

On Server 2016 and Windows 10 Version 1607 and later you can use the new PowerShell local user cmdlets: Add-LocalGroupMember -Group Administrators -Member username This was added in Windows Management Framework (WMF) 5.1. The Microsoft.PowerShell.LocalAccounts module works fine on 2012 R2 if you just copy the files into a $env:PsModulePath location.


21

• How does a sysadmin improve their shell scripting? Practice, mixed with drive. It sounds trite, but you have to want to get better, in addition to practice. If you don't truly enjoy scripting, you can be forced to do it for years when you have to and never really get good at it. If you don't want to get better, you could sit next to the best scripter in ...


20

You could use Azure CLI to upload id_rsa to Azure Key Vault. azure keyvault secret set --name shui --vault-name shui --file ~/.ssh/id_rsa You could use -h to get help. --file <file-name> the file that contains the secret value to be uploaded; cannot be used along with the --value or --json-value flag You could also download secret ...


17

I am surprised nobody mentioned plink from the putty-tools package in Ubuntu: plink user@domain -pw mypass [cmd] It also available on Windows and the syntax is mostly compatible with the openssh client.


17

The cookbook_file and template resources support a "cookbook" parameter that specifies which cookbook contains the source file. Then you could create a "commons" cookbook where those files live as a single entity. For example: % cookbooks/commons cookbooks/commons |-- files | `-- default | `-- master.conf `-- templates `-- default `-- ...


14

You can use the COM-based Task Scheduler Scripting objects: ($TaskScheduler = New-Object -ComObject Schedule.Service).Connect("localhost") $MyTask = $TaskScheduler.GetFolder('\').GetTask("My Task") $MyTask.Enabled = $false To enable the task again: $MyTask.Enabled = $true The above will only work if the shell is elevated and you are a local Administrator ...


13

I believe, ultimately, the correct answer is "Fix your application". However, you may not be able to for any number of reasons. That being said... Which version of Windows? In Vista/2008 and up, you can tie Scheduled Tasks to specific Event IDs. In the System event log, Event ID 19 from WindowsUpdateClient, indicates successful WUA Update Installation. ...


13

After you copy your keyfile to the server: ssh-copy-id -i ~/.ssh/id_rsa_for_scp legendaryuser@192.168.1.1 (To simplify the example, we will assume the client's machine ~/.ssh/config is already configured. For more details about ~/.ssh/config run man ssh_config) Host testmachine Hostname 192.168.1.1 User legendaryuser BatchMode yes ...


12

SSH single sign-on is usually achieved with public key authentication and an authentication agent. You could easily add your test VM key to an existing auth agent (see example below). Other methods such as gssapi/kerberos exist but are more complex. sshpass In situations where password is the only authentication method available, sshpass can be used to ...


12

Yes, for both Linux and Windows you can build desired state config files that can: Enable or disable server roles and features Manage registry settings Manage files and directories Start, stop, and manage processes and services Manage groups and user accounts Deploy new software Manage environment variables Run Windows PowerShell scripts Fix a configuration ...


12

I don't think you can, I usually create separate files to hold conditional variable collections and use a when clause to include them on a specific condition: - include_vars: test_environment_vars.yml when: global_platform == "test" - include_vars: staging_environment_vars.yml when: global_platform == "staging" - include_vars: prod_environment_vars....


11

I've came across similar request today, but I'm not a fan of a exec if things can be solved by any other means. So I've chosen a different path and written a simple custom type for 'yumgroup'. Just put these files in any module in your modulepath and that's it: "modulename/lib/puppet/provider/yumgroup/default.rb" Puppet::Type.type(:yumgroup).provide(:...


11

For Windows 7, I've broken this down into smaller chunks so that I have more control. This assumes that you have a directory structure like this and that you download the .msu updates from Microsoft to the updates folder: c:\ - Win7 --- mount --- updates --- stagedupdates You can obviously modify this to your liking. I also manually download the ...


11

Start your batch: powershell.exe -Command "Start-Process cmd -Verb RunAs" ... rest of script ... This will open an elevated command prompt Keep in mind for this to work the user would need to have admin privilege on the box. If the user is not a local admin you will have the use the /savecred switch, this is a big security hole as then the user and can ...


10

The previous answer by Shengbao Shui shows the command to store a secret using the Azure CLI 1.0 (Node). For Azure CLI 2.0 (Python) use the following syntax: Set / Store Key: az keyvault secret set --vault-name 'myvault' -n 'secret-name' -f '~/.ssh/id_rsa' Arguments: Arguments --name -n [Required]: Name of the secret. --vault-name [Required]: ...


10

Ansible allows one of following forms to define variable conditionally: test: var1: "{% if my_group_var %}value{% else %}other_value{% endif %}" var2: "{{'value' if (my_group_var) else 'other_value'}}" Combining above syntax with vars lookup we can load complex vars (list in this case): test_value_when_my_group_var_is_true: var1: value ...


10

You might need incrond (inotify cron daemon) which will monitors changes on files and then execute scripts. Incrond can monitor add new file, modify, delete and many more. This is an article shows what event incrond can monitor with some example. Example for your case, you might create the file /etc/incron.d/data_upload with the contents /tmp/data_upload ...


9

I have the benefit of understanding the size and complexity of your environment. Seeing as you work for a cloud/hosting provider, it's safe to assume that you have a large number of small-medium sized environments (10-100 servers). There are certainly daily tasks that are done by the jr. engineers and NOC staff that are repetitive (creating user accounts, ...


8

In powershell: $wmi = Get-WmiObject win32_networkadapterconfiguration -filter "ipenabled = 'true'" $DNSServers = "8.8.8.8","8.8.4.4" $wmi.SetDNSServerSearchOrder($DNSServers) To revert: $wmi.SetDNSServerSearchOrder() (no parameters=null, this will put it back in automatic mode) References: http://fatbeards.blogspot.com/2008/06/change-dnswins-ip-on-...


8

Cobbler was designed for this.


7

Solution that would work: Install following applications WDS (windows deployment services) Use WDS to provide PXE boot. All laptops can boot via PXE into WDS server. WDS will host MDT boot images MDT (Microsoft Deployment Tool) Create task sequences to capture your default Windows 7 install Create task sequences to install your captured Windows 7 image ...


7

Devcon does work. You just need to make sure you are targeting the right version of devcon for your operation system. Take a look at this link http://freneticrapport.blogspot.com/2011/05/windows-hiddennot-connected-device.html. For installing the correct devcon version for your OS: Install the Windows Driver Kit Go to Start -> Programs -> Development ...


7

$ echo "* hard nofile 102400" >> /etc/security/limits.conf $ echo "* soft nofile 102400" >> /etc/security/limits.conf $ sysctl -w fs.file-max=102400 $ sysctl -p The 4 steps can change your system's limits immediately, and can still work after your reboot. You can change the number "102400" to the number of max open-file in your linux system as ...


7

As long as you control the client, you could use FTPFS on the client, then rsync the local directory to the apparently-local-but-really-mounted-via FTPFS directory. I understand that FTPFS is now part of LUFS. Edit: I'd love to link to a tutorial, but I normally just start with the project wiki, and something seems to be up with sourceforge right now. ...


7

You could parse /var/log/messages, but I wouldn't. I'd write a udev rule that ran a script when you connect/disconnect the device. There's some more information on it here I've copied the salient points in case that site goes down: Rule files are stored in the /etc/udev/rules.d/ directory. There's some advice from the README in that directory on ...


Only top voted, non community-wiki answers of a minimum length are eligible