SSH Key – Public Key Authentication
Ich habe das alte Script auf der Seite durch dieses ersetzt. Was macht das Script genau ?
Es kopiert den SSH-Key auf ein anderes System um einen SSH-Login ohne Passworteingabe zu ermöglichen. Ist oft für Script wie Nagios, Backups usw. nötig.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | #!/bin/bash # kumar.mcmillan -at- farmdev.com function usage() { echo "" echo "Authorizes a host for automatic SSH use by sending your key to the remote host ..." echo "Usage: $0 remote_host_to_authorize [username:=defaults to current username]" echo "" } function cleanup() { if [ -f $TEMP_PUB_KEY_XFER ] then rm $TEMP_PUB_KEY_XFER fi } function exit_on_error() { cleanup exit 1 } if [ $# -lt 1 -o "$1" = "-h" -o "$1" = "--help" ] then usage exit 0 fi PUB_KEY=~/.ssh/id_dsa.pub if [ $# -eq 2 ]; then USER=$2 else USER=`whoami` fi HOST_TO_AUTH=$1 TEMP_PUB_KEY_XFER=/tmp/$USER"_TEMP_KEY" echo "checking for $PUB_KEY ..." if [ ! -f $PUB_KEY ]; then echo "generating your dsa public key (leave passphrase blank and save to $PUB_KEY when prompted) ..." ssh-keygen -t dsa if [ $? -ne 0 ]; then echo "ssh-keygen failed" exit_on_error fi fi echo "OK" echo "for the following commands you will be asked to supply your password for $HOST_TO_AUTH :" echo "copying a temp pub key to $HOST_TO_AUTH ..." cat $PUB_KEY > $TEMP_PUB_KEY_XFER chmod 700 $TEMP_PUB_KEY_XFER echo "OK" remote_key=`basename $TEMP_PUB_KEY_XFER` scp $TEMP_PUB_KEY_XFER $USER@$HOST_TO_AUTH:~/$remote_key if [ $? -ne 0 ]; then echo "scp failed" exit_on_error fi echo "authorizing $HOST_TO_AUTH for automatic SSH use ..." ssh $USER@$HOST_TO_AUTH "cat ~/$remote_key >> ~/.ssh/authorized_keys; rm ~/$remote_key" if [ $? -ne 0 ]; then echo "ssh failed" exit_on_error fi echo "OK" cleanup echo "authorization successful! you can now login automatically to $HOST_TO_AUTH" exit 0 |
VMWare Tools installieren
Da immer wieder mal Anfragen über das Installieren von VMWare kommen, hier eine kleine Anleintung unter Debian. War zwar der Meinung dass das Thema schon durch ist, aber egal.
1.) Installation der Kompiliertools in der VM
aptitude install autoconf automake binutils cpp gcc linux-headers-$(uname -r) make psmisc
2.) VMWare zu Installation auffordern
In VMWare auf VM -> Install VMWare Tools
3.) Mounten der VMWare Tools CD in der VM
mount /dev/cdrom /mnt/
4.) Entpacken der VMWare Tools nach /tmp
tar -C /tmp -zxvf /mnt/VMwareTools-xxx.tar.gz
5.) VMWare Tools CD wieder aushängen
umount /mnt
6.) VMWare Tools Installieren
cd /tmp/vmware-tools-distrib ./vmware-install.pl
Es werden jetzt einige Fragen gestellt und danch die Module kompiliert. Thats it!
SSH Public Key
Hier ein kleines Script welches hilft den SSH Public Key auf andere Maschinen zu übertragen
#!/bin/sh echo echo This script will help you setup ssh public key authentication. host=dummy while [ -n "$host" ]; do echo -n "SSH server: " read host if [ -n "$host" ]; then echo -n "user[$USER]: " read usr if [ -z "$usr" ]; then usr=$USER fi echo "Setting up RSA authentication for ${usr}@${host}..." if [ -f ~/.ssh/id_rsa.pub ]; then echo "RSA public key OK." else ssh-keygen -t rsa -f ~/.ssh/id_rsa -N "" fi scp -P22 ~/.ssh/id_rsa.pub ${usr}@${host}:~/ ssh ${usr}@${host} -p22 "if [ ! -d ~/.ssh ]; then mkdir ~/.ssh fi cat ~/id_rsa.pub >> ~/.ssh/authorized_keys chmod 0600 ~/.ssh/authorized_keys rm ~/id_rsa.pub" echo echo "You should see the following message without being prompted for anything now..." echo ssh ${usr}@${host} "echo !!! Congratulations, you are now logged in as ${usr}@${host} !!!" echo echo "If you were prompted, public key authentication could not be configured..." echo echo "Enter a blank servername when done." echo fi done echo "End of configuration."
Colorfull Shell
Linux muss nicht immer schwarz/weiß sein. Es geht auch Bunt
Darum habe ich hier einfach mal ein paar Punkte dazu erfasst.
ls mit buntem Output
Um den Befehl "ls" etwas übersichtlicher zu gestalten kann in der ".bashrc" eine kleine anpassung gemacht werden. Dazu müssen wir in das Homeverzeichniss des jeweiligen Benutzers und die Datei mit öffnen
# cd # vi .bashrc
Danch sollte wir die Datei folgendermasse bearbeiten:
# ~/.bashrc: executed by bash(1) for non-login shells. export PS1='\h:\w\$ ' umask 022 # You may uncomment the following lines if you want `ls' to be colorized: export LS_OPTIONS='--color=auto' eval `dircolors` alias ls='ls $LS_OPTIONS' alias ll='ls $LS_OPTIONS -l' alias l='ls $LS_OPTIONS -lA' # Some more alias to avoid making mistakes: # alias rm='rm -i' # alias cp='cp -i' # alias mv='mv -i'
Sobald sich dann der Benutzer neuanmeldet sollte die Aussage von "ls -l" so aussehen:

Vim / Farben und Code Syntax
Vim (vi Improved) kann sehr gut bei der Suche in Configs oder beim Programmieren durch seine Farben und Syntax helfen. Wer sich nicht sicher ist das er "vim" hat kann es sonst auch einfach nachinstallieren.
# apt-get install vim
Danch am besten gleich als standard Editor setzen
# update-alternatives --config editor
Nach dem wir jetzt vim installier haben / hatten können wir die vimrc anpassen
# vi /etc/vim/vimrc
Danch müss die vimrc so angepasst werden wie diese.
" All system-wide defaults are set in $VIMRUNTIME/debian.vim (usually just
" /usr/share/vim/vimcurrent/debian.vim) and sourced by the call to :runtime
" you can find below. If you wish to change any of those settings, you should
" do it in this file (/etc/vim/vimrc), since debian.vim will be overwritten
" everytime an upgrade of the vim packages is performed. It is recommended to
" make changes after sourcing debian.vim since it alters the value of the
" 'compatible' option.
" This line should not be removed as it ensures that various options are
" properly set to work with the Vim-related packages available in Debian.
runtime! debian.vim
" Uncomment the next line to make Vim more Vi-compatible
" NOTE: debian.vim sets 'nocompatible'. Setting 'compatible' changes numerous
" options, so any other options should be set AFTER setting 'compatible'.
set compatible
" Vim5 and later versions support syntax highlighting. Uncommenting the next
" line enables syntax highlighting by default.
syntax on
" If using a dark background within the editing area and syntax highlighting
" turn on this option as well
set background=dark
" Uncomment the following to have Vim jump to the last position when
" reopening a file
"if has("autocmd")
" au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
" \| exe "normal g'\"" | endif
"endif
" Uncomment the following to have Vim load indentation rules according to the
" detected filetype. Per default Debian Vim only load filetype specific
" plugins.
"if has("autocmd")
" filetype indent on
"endif
" The following are commented out as they cause vim to behave a lot
" differently from regular Vi. They are highly recommended though.
set showcmd " Show (partial) command in status line.
set showmatch " Show matching brackets.
set ignorecase " Do case insensitive matching
set smartcase " Do smart case matching
set incsearch " Incremental search
set autowrite " Automatically save before commands like :next and :make
set hidden " Hide buffers when they are abandoned
"set mouse=a " Enable mouse usage (all modes) in terminals
" Source a global configuration file if available
" XXX Deprecated, please move your changes here in /etc/vim/vimrc
if filereadable("/etc/vim/vimrc.local")
source /etc/vim/vimrc.local
endif
Das ganze speichern ":wq" und dann sollte auch vim bunt sein

Wem das ganze noch nicht passt kann noch die Hintergrundfarbe verändern (hell/dunkel) oder sonstige Änderungen vornehmen.
Linux Logo
Es gibt ein kleines und nette Programm "linux_logo" mit dem solche Logos erstellen kann

Die installation ist unter Debian wieder sehr einfach
# apt-get install linuxlogo
Danach kann das Programm dirket auf der Shell gestart werden
# linux_logo
Und wer das Logo mit den Infos gleich bei jedem anmelden sehen will kan es in die motd packen
# cp /etc/motd /etc/motd.org # linux_logo -b > /etc/motd
