Tag Info

Hot answers tagged

143

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


96

Don't use a password. Generate a passphraseless SSH key and push it to your VM. If you already have an SSH key, you can skip this step… Just hit Enter for the key and both passphrases: $ ssh-keygen -t rsa -b 2048 Generating public/private rsa key pair. Enter file in which to save the key (/home/username/.ssh/id_rsa): Enter passphrase (empty for no ...


51

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


28

I wrote a program to block IP addresses like you're asking for a couple of years ago, but did it for a Customer as a work-for-hire. Since I ended up with some "spare" time this evening I opted to re-implement the whole thing from the ground up, write some useful documentation, and generally make it a presentable program. Since I've heard from multiple people ...


25

You can use pre-seeding for this, using the debconf-set-selections command to pre-answer the questions asked by debconf before installing the package. For example: debconf-set-selections <<< "postfix postfix/mailname string your.hostname.com" debconf-set-selections <<< "postfix postfix/main_mailer_type string 'Internet Site'" apt-get ...


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


20

Puppet sounds perfect for what you're trying to do, with the caveat that as of right now, there is no support for Windows. In your case, you would define a Server node in terms of all of the packages that are identical across the machines. Then, you define the individual hosts as nodes which inherit from Server, and set up the specific unique things for it. ...


19

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


18

Easy answer in three easy steps Generate a rsa keypair: # ssh-keygen then copy it on the server with one simple command: # ssh-copy-id hostname you can now log in without password: # ssh hostname


14

Add a ; /bin/bash to the end of your command line on the remote side? That is: spawn ssh -t root@marlboro "cd /tmp; ls -altr | tail; /bin/bash -i" Even better, change root's .bashrc to be something like this: PROMPT_COMMAND="cd /tmp && ls -altr | tail ; unset PROMPT_COMMAND" :)


12

Sure you don't want to use SSH keys rather than passwords? That way it's both secure and automatic.


12

If you want this globally: dpkg-reconfigure debconf Then configure it to be "noninteractive" If you just want it for single install run: DEBIAN_FRONTEND=noninteractive apt-get install PACKAGE


12

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


11

There are many ways that would help: remove the complete home directory and copy all files from /etc/skel back to the homedir. Change permissions afterwards. put the system in a virtual machine, make a snapshot and revert to the snapshot after lesson 1 find something like a kiosk mode in RHEL. Ubuntu has something like that, which automatically restores ...


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

Use expect: #!/usr/bin/expect -f # ./ssh.exp password 192.168.1.11 id set pass [lrange $argv 0 0] set server [lrange $argv 1 1] set name [lrange $argv 2 2] spawn ssh $name@$server match_max 100000 expect "*?assword:*" send -- "$pass\r" send -- "\r" interact Example: # ./1.ex password localhost ooshro spawn ssh ooshro@localhost ooshro@localhost's ...


11

First of all, don't just take my word for it! Test my suggestion out with this: select CONCAT('alter table ',TABLE_SCHEMA,'.',TABLE_NAME,' charset=utf8;') from information_schema.TABLES WHERE TABLE_SCHEMA != 'information_schema' limit 10; select CONCAT('alter table ',TABLE_SCHEMA,'.',TABLE_NAME,' alter column ',COLUMN_NAME,' charset=utf8;') from ...


10

Before doing any of this make sure you are familiar with the freebsd-update process, possible ramifications, and requirements. Like any automated update there is a chance it will screw up. Create the file /usr/local/etc/periodic/weekly/912.freebsd-update with the following: #!/bin/sh - # # # If there is a global system configuration file, suck it in. # if ...


10

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


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


9

Without installing ii: echo -e 'USER bot guest tolmoon tolsun\nNICK bot\nJOIN #channel\nPRIVMSG #channel :Ahoj lidi!\nQUIT\n' \ | nc irc.freenode.net 6667


9

You could use cron and the @reboot flag to schedule the shutdown if you add this to the root crontab: @reboot shutdown -h +30


9

The way we do this is to use a kickstart/preseed file to install & configure Puppet on our servers during the OS install. Then as long as you've preconfigured your Puppet manifest to do all your initial tasks, it'll happen automatically.


9

We use Cobbler and Puppet for build and configuration automation of both real and virtual machines. Cobbler ties together DHCP, PXE boot and Kickstart to make deployment nothing more than adding a machine profile and hitting the power button. For VMs, the koan command does the (in our case) Xen magic to get the installation started -- on the dom0 I just ...


8

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


8

This might not be any use to you, but you can do it with Perl: #!/usr/bin/perl use warnings; use strict; use Net::SSH::Perl; my $host = 'remote.serv.er'; my $user = 'root'; my $pass = 'hunter2'; my $ssh = Net::SSH::Perl->new('$host'); $ssh->login('$user', '$pass') or die "Oh noes! $!";


8

There exists a more direct command called pkill. Usage is as follows: $ pkill "process name here"


7

use console irc client apt-get install ii ii -i /tmp -s 192.168.1.2 echo "/PRIVMSG #teamchannel example.com: Alert! The server is rebooting now" > /tmp/irc/in


7

My answer to that question would always be: ask the users, in your case the developers. IT systems do not have an intrinsic value of their own, they always fulfill a role within the context of the business they are used in. Therefore the better you can make them do what is needed in that context, the better for the business. Some more specific answers: ...


7

Here is a simple 2 line script that performs this function $group = [ADSI]("WinNT://"+$env:COMPUTERNAME+"/administrators,group") $group.add("WinNT://$env:USERDOMAIN/usernameiwantoadd,user") For more information see Hey, Scripting Guy! How Can I Use Windows PowerShell to Add a Domain User to a Local Group? So there are a couple of notes. In the first ...



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