Posts from 2014-04

ssh key forwarding

posted on 2014-04-28 18:26:53

To enable ssh key forwarding on startup, use these in .bashrc or .zshrc:

eval $(ssh-agent|grep -v echo)
ssh-add > /dev/null

This has supressed output, and will work next time you login a new shell.

Further you have to have set these in your ssh config.

# Mind the indentation!
Host *
    ForwardAgent yes
    StrictHostkeyChecking no

    # if you want, try these
    User root
    VisualHostkeyChecking yes

User root is the user that will be used, if the username is omitted with the ssh command, and you do not want to use the current user on your machine. VisualHostkeyChecking shows the graphical fingerprint of the machine you are connecting to.

On Linux, for system-wide changes these go into /etc/ssh_config. If you just want to change for a specific user, just change the /home/<username>/.ssh/config file.

User specific changes on windows go into C:\Users\<username>\.ssh\config IIRC.

A proper du / disk usage alias

posted on 2014-04-26 21:18:50

This finds you all files in the current folder, sorts them from biggest to lowest, and puts human readable file sizes on it.

function dus () {
du --max-depth=0 -k * | sort -nr | awk '{ if($1>=1024*1024) {size=$1/1024/1024; unit="G"} else if($1>=1024) {size=$1/1024; unit="M"} else {size=$1; unit="K"}; if(size<10) format="%.1f%s"; else format="%.0f%s"; res=sprintf(format,size,unit); printf "%-8s %s\n",res,$2 }'}

Usage:

$ dus

Sample output:

[sjas@ctr-014 ~]% dus
3.1G     Downloads
1.7G     VMware-vCenter-Server-Appliance-5.5.0.5100-1312297-system.vmdk
1.4M     blog
576K     work
80K      hs_err_pid25560.log
80K      hs_err_pid24938.log
8.0K     bin
4.0K     yankring_history_v2.txt

This should be included in all linux distros by default.

Editing shell commands in vim

posted on 2014-04-26 18:41:02

Having a long shell command, wishing for an easier way to edit it? Not wanting to have the vim bindings (set -o vi IIRC) enabled in bash, since they, lets face it, could use alot of improvement? (Or a proper zsh prompt, so you see which mode you are currently in, maybe?)

$ Ctrl+X, Ctrl+E

Press this while being in the bash console. Once you save and exit vim, you have your output changes in the shell again, and off you go.

Generating system noise

posted on 2014-04-26 17:50:17

When generating certificates with openssl, trouble might arise as there is not enough randomness on your system.

Fire up a new console and try:

$ find /

This should do. Ctrl+C,Ctrl+D when the keygen is done.

Installing the Oracle JDK/JRE on Debian

posted on 2014-04-25 12:52:31

Sometimes you need the reference implementation (And not, i.e. the OpenJDK one that is easily available from the package repositories...) from the Oracle homepage. Might be you need exactly Java in v6 or v7 for IPMI for your Supermicro servers.

In this case several problem pop up:

  1. Oracle only provides .rpm and .tar.gz downloads.
  2. When getting the .tar.gz, might have problems installing it.
  3. Setting new package resources in /etc/apt/sources.list might also cause other problems, depending on the information you dig up from the internet.
  4. If No.3 works, you will run into the same trouble again, once you have to redo and regoogle what you did. (Of course this never happens. Haha.)
  5. Depending on what you install, you might miss the Java Web Start executable. Or it might be wrongly installed. (Of course, this never happens, either...)

So here is a better approach, which is easier to reproduce and will work.

First download the install of choice. (Choose the 32bit .tar.gz or the 64 bit one, according to your system. I.e. jdk-7u55-linux-x64.tar.gz)

$ apt-get install java-package
$ make-jpkg jdk-7u55-linux-x64.tar.gz

Say yes and ok, and let it work it's magic. Do not worry about error messages, at least in my case they were not of importance.

$ dpkg -i oracle-j2re1.7_1.7.0+update55_amd64.deb

And you are mostly done.

Only problem left might be that all is installed correctly, just the javaws not.

Check by running:

$ javaws

If this does not work, due to previously installed IcedTea implementation or whatnot, try this:

$ cd /etc/alternatives
$ ls java*

Then everything should point to the oracle install.

In my case everything did. Except the Web Start Link.

$ rm javaws
$ ln -s /usr/lib/jvm/java-7-oracle/bin/javaws javaws

Afterwards run

$ javaws

and you might see something like this:

[root@ctr-014 ~/Downloads]% javaws
Java(TM) Web Start 10.55.2.13-fcs 
Usage:  javaws [run-options] <jnlp-file>
        javaws [control-options]

where run-options include:
  -verbose              display additional output
  -offline              run the application in offline mode
  -system               run the application from the system cache only
  -Xnosplash            run without showing a splash screen
  -J<option>            supply option to the vm
  -wait                 start java process and wait for its exit

control-options include:
  -viewer               show the cache viewer in the java control panel
  -clearcache           remove all non-installed applications from the cache
  -uninstall            remove all applications from the cache
  -uninstall <jnlp-file>                remove the application from the cache
  -import [import-options] <jnlp-file>  import the application to the cache

import-options include:
  -silent               import silently (with no user interface)
  -system               import application into the system cache
  -codebase <url>       retrieve resources from the given codebase
  -shortcut             install shortcuts as if user allowed prompt
  -association          install associations as if user allowed prompt

Done.

Windows' cat

posted on 2014-04-21 18:16:39

The linux equivalent of cat (for displaying the contents of a file on the console) is type.

Windows run commands list

posted on 2014-04-11 10:31:03

Accessing most system programs in windows is done easiest through the RUN command box. Start it via WIN + R. After you have had a lot of different windows systems to administer, you may wonder how you lived without this.

Task Manager                    taskmgr         CTRL+SHIFT+ESC
Control Panel                   control
System Information              msinfo32
Version Reporter Applet         winver
Firewall                        firewall.cpl
Downloads                       downloads
Recent Files                    recent
Windows Update                  wuapp
Shell                           cmd
Powershell                      powershell
Windows Explorer                explorer        WIN+E
System Properties               sysdm.cpl
Services                        services.msc
Shared Folders                  fsmgmt.msc
User Account                    control /name Microsoft.UserAccounts
User Account Control Settings   useraccountcontrolsettings
Advanced User Accounts          netplwiz
Authorization Manager           azman.msc
Windows Activation Client       slui
Screen Resolution               desp.cpl
Remote Desktop Connection       mstsc
Power Options                   powercfg.cpl
On Screen Keyboard              osc
Mouse Settings                  main.cpl
Disk Management                 diskmgmt.cpl
Disk Cleanup                    cleanmgr
Disk Defragmenter               dfrgui
Language Pack Installer         lpksetup
Local Group Policy Editor       gpedit.msc
Local Users and Groups          lusrmgr.msc
Local Security Policy           secpol.msc
Computer Management             compmgmt.msc
Certificates                    certmgr.msc
Hardware Wizard                 hdwwiz

Exit VMWare VSphere Console

posted on 2014-04-10 16:56:31

Being stuck in the VSphere console while working on a host? (You cannot exit to your host OS.)

Do

Ctrl+Alt

and be happy.

Postgresql 9.3 install error on Debian Wheezy

posted on 2014-04-08 20:14:09

When trying to install the newest postgres DB on debian 7.x according to the howto on the postgres howto this causes trouble:

Create the file /etc/apt/sources.list.d/pgdg.list, and add a line for the repository deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main

If instead of pasting the deb http://apt.postgresql... line into the sources list in the parent folder, everything works as expected...

Find out which linux distro & version you are running

posted on 2014-04-08 09:21:20

Ever wondered what linux distribution or which version you are running?
Try:

$ lsb_release -a

or

$ cat /etc/*-release

This works on Fedora and Debian at least, haven't tested it on other distributions.

clusterssh on Fedora

posted on 2014-04-05 12:32:28

Ever had to administer several linux machines after another with quite the same configuration? Or had to work on several machines while being on really bad connection forcing you to reconnect and having to reopen half a dozen shell windows or even more?

clusterssh to the rescue!

Its features:

  • Connect to several servers at once.
  • Send all terminals the same input AT ONCE.

Start with getting the packages:

sudo yum install clusterssh -y

Install.

Afterwards its a nice idea to create serveraliases:

qwer name@box1.tv noname@box2.ru
asdf user@server1.xy anotheruser@srv2.yz

both qwer asdf

Put this either in /etc/clusters or in $HOME/.csshrc.

Upon calling cssh both clusterssh will try to connect to name@box1.tv noname@box2.ru user@server1.xy anotheruser@srv2.yz. Of course, cssh qwer and cssh asdf can be used separately, too.

Also you can leave the username out anyway, when connecting as root to all other boxes. :)
Via the -l you can specify the user, as which you want to log in on the remote machines. Go look at the examples on the manpage yourself, you might like this tool very much.

Linux terminal chat

posted on 2014-04-05 12:25:46

In the linux shell there is a possibility to have a chat between logged in users.

Terminal chat is used like this:

# show users logged in on the server/workstation
$ w

# open chat [i.e. 'write sjas pts/4']
$ write user <terminal>

# logout, same as in regular console
CTRL+D

Even though you might not need this often, it can be quite helpful while fixing things together on a server while working over ssh from remote machines.

Proper workspace switching in XFCE

posted on 2014-04-04 13:51:23

To change the jump-to-workspace and related shortcuts:

Applications Menu -> Settings -> Window Manager

Tab: Keyboard

Ctrl-1 to Ctrl-4 work pretty decent, instead of the previously bound Function keys.

List available disks in Fedora 20

posted on 2014-04-04 13:41:11

Show all available devices via console:

# fdisk -l /dev/[sh]d?

Lists all hdx/sdx devices and its partitions.

This blog covers .csv, .htaccess, .pfx, .vmx, /etc/crypttab, /etc/network/interfaces, /etc/sudoers, /proc, 10.04, 14.04, AS, ASA, ControlPanel, DS1054Z, GPT, HWR, Hyper-V, IPSEC, KVM, LSI, LVM, LXC, MBR, MTU, MegaCli, PHP, PKI, R, RAID, S.M.A.R.T., SNMP, SSD, SSL, TLS, TRIM, VEEAM, VMware, VServer, VirtualBox, Virtuozzo, XenServer, acpi, adaptec, algorithm, ansible, apache, apachebench, apple, arcconf, arch, architecture, areca, arping, asa, asdm, awk, backup, bandit, bar, bash, benchmarking, binding, bitrate, blackarmor, blowfish, bochs, bond, bonding, booknotes, bootable, bsd, btrfs, buffer, c-states, cache, caching, ccl, centos, certificate, certtool, cgdisk, cheatsheet, chrome, chroot, cisco, clamav, cli, clp, clush, cluster, coleslaw, colorscheme, common lisp, console, container, containers, controller, cron, cryptsetup, csync2, cu, cups, cygwin, d-states, database, date, db2, dcfldd, dcim, dd, debian, debug, debugger, debugging, decimal, desktop, df, dhclient, dhcp, diff, dig, display manager, dm-crypt, dmesg, dmidecode, dns, docker, dos, drivers, dtrace, dtrace4linux, du, dynamictracing, e2fsck, eBPF, ebook, efi, egrep, emacs, encoding, env, error, ess, esx, esxcli, esxi, ethtool, evil, expect, exportfs, factory reset, factory_reset, factoryreset, fail2ban, fbsd, fedora, file, filesystem, find, fio, firewall, firmware, fish, flashrom, forensics, free, freebsd, freedos, fritzbox, fsck, fstrim, ftp, ftps, g-states, gentoo, ghostscript, git, git-filter-branch, github, gitolite, gnutls, gradle, grep, grml, grub, grub2, guacamole, hardware, haskell, hdd, hdparm, hellowor, hex, hexdump, history, howto, htop, htpasswd, http, httpd, https, i3, icmp, ifenslave, iftop, iis, imagemagick, imap, imaps, init, innoDB, innodb, inodes, intel, ioncube, ios, iostat, ip, iperf, iphone, ipmi, ipmitool, iproute2, ipsec, iptables, ipv6, irc, irssi, iw, iwconfig, iwlist, iwlwifi, jailbreak, jails, java, javascript, javaws, js, juniper, junit, kali, kde, kemp, kernel, keyremap, kill, kpartx, krypton, lacp, lamp, languages, ldap, ldapsearch, less, leviathan, liero, lightning, links, linux, linuxin3months, lisp, list, livedisk, lmctfy, loadbalancing, locale, log, logrotate, looback, loopback, losetup, lsblk, lsi, lsof, lsusb, lsyncd, luks, lvextend, lvm, lvm2, lvreduce, lxc, lxde, macbook, macro, magento, mailclient, mailing, mailq, manpages, markdown, mbr, mdadm, megacli, micro sd, microsoft, minicom, mkfs, mktemp, mod_pagespeed, mod_proxy, modbus, modprobe, mount, mouse, movement, mpstat, multitasking, myISAM, mysql, mysql 5.7, mysql workbench, mysqlcheck, mysqldump, nagios, nas, nat, nc, netfilter, networking, nfs, nginx, nmap, nocaps, nodejs, numberingsystem, numbers, od, onyx, opcode-cache, openVZ, openlierox, openssl, openvpn, openvswitch, openwrt, oracle linux, org-mode, os, oscilloscope, overview, parallel, parameter expansion, parted, partitioning, passwd, patch, pdf, performance, pfsense, php, php7, phpmyadmin, pi, pidgin, pidstat, pins, pkill, plesk, plugin, posix, postfix, postfixadmin, postgres, postgresql, poudriere, powershell, preview, profiling, prompt, proxmox, ps, puppet, pv, pvecm, pvresize, python, qemu, qemu-img, qm, qmrestore, quicklisp, r, racktables, raid, raspberry pi, raspberrypi, raspbian, rbpi, rdp, redhat, redirect, registry, requirements, resize2fs, rewrite, rewrites, rhel, rigol, roccat, routing, rs0485, rs232, rsync, s-states, s_client, samba, sar, sata, sbcl, scite, scp, screen, scripting, seafile, seagate, security, sed, serial, serial port, setup, sftp, sg300, shell, shopware, shortcuts, showmount, signals, slattach, slip, slow-query-log, smbclient, snmpget, snmpwalk, software RAID, software raid, softwareraid, sophos, spacemacs, spam, specification, speedport, spi, sqlite, squid, ssd, ssh, ssh-add, sshd, ssl, stats, storage, strace, stronswan, su, submodules, subzone, sudo, sudoers, sup, swaks, swap, switch, switching, synaptics, synergy, sysfs, systemd, systemtap, tar, tcpdump, tcsh, tee, telnet, terminal, terminator, testdisk, testing, throughput, tmux, todo, tomcat, top, tput, trafficshaping, ttl, tuning, tunnel, tunneling, typo3, uboot, ubuntu, ubuntu 16.04, udev, uefi, ulimit, uname, unetbootin, unit testing, upstart, uptime, usb, usbstick, utf8, utm, utm 220, ux305, vcs, vgchange, vim, vimdiff, virtualbox, virtualization, visual studio code, vlan, vmstat, vmware, vnc, vncviewer, voltage, vpn, vsphere, vzdump, w, w701, wakeonlan, wargames, web, webdav, weechat, wget, whois, wicd, wifi, windowmanager, windows, wine, wireshark, wpa, wpa_passphrase, wpa_supplicant, x11vnc, x2x, xfce, xfreerdp, xmodem, xterm, xxd, yum, zones, zsh


Unless otherwise credited all material Creative Commons License by sjas