730

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


56

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 ...


36

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 ...


31

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 ...


29

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.


29

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.


29

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 ...


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 ...


21

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 ...


15

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]: ...


15

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 ...


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 ...


14

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....


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. ...


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 ...


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

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 ...


11

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, ...


7

I prefer passh https://github.com/clarkwang/passh sshpass is broken by design. when the ssh server is not added already in my known_hosts, sshpass will not show me the message to add the server to my known hosts, passh do not have this problem. Login to a remote server: $ passh -p password ssh user@host


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

services.msc /computer=Gregg1 I thought this wasn't possible, but after I found this other question & answer it worked wonders for me! They listed the better tool (Computer Management) which shows Event Viewer, Services, Disk Management, Device Manager: compmgmt.msc -a /computer=Gregg1 The -a doesn't appear to be necessary, I am honestly confused what ...


7

How does a sysadmin improve their shell scripting? How does one get better at anything? Read books, attend classes, and then apply the principles learned. (Or a combination of the methods.) This is over simplified intentionally since there isn't anything special about learning scripting over learning how to cook or how to repair a car. Is there still a ...


7

You can launch your spot instance with a persistent EBS root volume (or attach a separate EBS volume post-boot). The EBS volume will remain after your spot instance terminates. See http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/concepts-spot-instances-applications-ebs.html


7

You can do it all in PowerShell Get-WindowsFeature | ? { $_.Installed } | Export-Clixml .\installed.xml Copy the xml where is needs to go to, somewhere the new server can access it. Import-Clixml <path to xml>\installed.xml | Install-WindowsFeature


7

If I understood correctly you are looking for "Wake on LAN", which is supported by DELL Optiplex systems (at least in principle). Enable "Wake on LAN" in the BIOS of the target. Disable "Deep Sleep" in the BIOS of the target. On your "other" Computer (assuming it is in the same LAN) install wakeonlan. This tool can send "magic packets" to the target. Now ...


6

Use a Kickstart or equivalent process to manage the build. Use a configuration management product like Puppet to deploy your settings. You can also use a little bit of scripting magic to kick off the configuration management at the end of your build to make it a seamless experience. My script sets a static IP, configures OSSEC and performs a couple ...


6

Depending on your automation needs, perhaps Ansible would be a good fit for you. It can nicely manage things like prompting for password, prompting for sudo password, various ways of changing use, securely using encrypted secrets (vault). If that’s not suitable, I would suggest Expect, as suggested in another answer.


6

This can be configured using the EC2ConfigService Settings application that's included on the standard Windows instance builds (or available separately from the AWS Developer Tools site.) After launching your instance, select Start -> All Programs -> EC2ConfigService Settings. Access the 'Storage' tab, check the box for 'Map volume names to drive letters.' ...


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