Zwei PDF-Dateien verbinden und verkleinern

24.08.2015 - Lesezeit: ~1 Minute

Die vom Kunden gelieferte PDF-Datei soll verdoppelt werden. Dazu die Datei in ein leeres Verzeichnis kopieren und umbenennen.

$ cp 2015_VE_Komplett.pdf ./xxx/2015_VE_Komplett_1.pdf 
$ cp 2015_VE_Komplett.pdf ./xxx/2015_VE_Komplett_2.pdf 

Mit pdftk die beiden Dateien verbinden.

$ pdftk ./xxx/*.pdf cat output ./xxx/xxx.pdf

Mit gs die erzeugte Datei verkleinern:

$ gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -sOutputFile=./xxx/2015_VE_Komplett.pdf ./xxx/xxx.pdf
Tags: Linux-Scripte pdftk gs

A5 Blatt scannen und in PDF-Datei wandeln (-dEPSCrop)

10.11.2014 - Lesezeit: ~1 Minute
  • Scannen des A5.Blattes
    scanimage --format=pbm --resolution 300 -x 148 -y 210 > /tmp/scantopdf.pbm
  • Wandeln der Bilddatei in Postscript Datei
    pnmtops -equalpixels -dpi 300 -width 4 -height 8 /tmp/scantopdf.pbm > /tmp/scantopdf.ps
  • Wandeln der Postscript Datei in PDF-Datei (dabei bewirkt der Schalter -dEPSCrop, dass die PDF-Datei die Abmessungen der Postscript-Datei erhält)
    ps2pdf -dEPSCrop /tmp/scantopdf.ps  /tmp/scantopdf_08.pdf
Tags: Linux-Scripte

Kein ssh-login auf MyBookLive mehr [gelöst]

03.05.2014 - Lesezeit: 6 Minuten

In meinem Backup-Script sichere ich seit langer Zeit meine Daten auf mybooklive.fritz.box (das ist mein NAS). Von einem Tag auf den anderen funktioniert das Script nicht mehr.

Kurzfassung der Lösung

  • in der Datei /etc/ssh/sshd_config auf MyBookLive fehlten die AllowUsers
    AllowUsers root wnf bine
  • Das Home-Verzeichnis des Users wnf gehörte nicht mehr wnf sondern nobody
    # chown wnf:share /shares/wnf

Woran kann das liegen?

Der Ping funktioniert

$ ping mybooklive.fritz.box
PING mybooklive.fritz.box (192.168.1.6) 56(84) bytes of data.
64 bytes from mybooklive (192.168.1.6): icmp_req=1 ttl=64 time=0.197 ms
$ ping mybooklive.local
PING mybooklive.local (192.168.1.6) 56(84) bytes of data.
64 bytes from mybooklive (192.168.1.6): icmp_req=1 ttl=64 time=0.161 ms
$ ping mybooklive
PING mybooklive (192.168.1.6) 56(84) bytes of data.

Jetzt versuche ich mich per ssh auf MyBookLive anzumelden.

$ ssh root@mybooklive.fritz.box
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
37:75:0e:15:12:78:30:55:11:fb:9b:aa:21:b4:df:05.
Please contact your system administrator.
Add correct host key in /home/wnf/.ssh/known_hosts to get rid of this message.
Offending RSA key in /home/wnf/.ssh/known_hosts:7
  remove with: ssh-keygen -f "/home/wnf/.ssh/known_hosts" -R mybooklive.fritz.box
RSA host key for mybooklive.fritz.box has changed and you have requested strict checking.
Host key verification failed.

Ja, wenn der ssh-Zugriff auf MyBookLive nicht mehr funktioniert, dann kann die Datensicherung natürlich auch nicht mehr funktionieren.

Also wie angegeben den alten Schlüssel entfernen:

$ ssh-keygen -f "/home/wnf/.ssh/known_hosts" -R mybooklive.fritz.box
/home/wnf/.ssh/known_hosts updated.
Original contents retained as /home/wnf/.ssh/known_hosts.old

Und dann beim Anmelden per ssh wieder herstellen:

wnf@c2012:~$ ssh root@mybooklive.fritz.box
The authenticity of host 'mybooklive.fritz.box (192.168.1.6)' can't be established.
RSA key fingerprint is 37:75:0e:15:12:78:30:55:11:fb:9b:aa:21:b4:df:05.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'mybooklive.fritz.box' (RSA) to the list of known hosts.
Warning: the RSA host key for 'mybooklive.fritz.box' differs from the key for the IP address '192.168.1.6'
Offending key for IP in /home/wnf/.ssh/known_hosts:4
Are you sure you want to continue connecting (yes/no)? yes
root@mybooklive.fritz.box's password: 

Als normaler User kann ich mich immer noch nicht anmelden. Bei der Kontrolle der Datei /etc/ssh/sshd_config auf MyBookLive fiel mir auf, dass in der Zeile

AllowUsers root

die anderen Benutzer fehlten

AllowUsers root wnf bine

außerdem

#AuthorizedKeysFile     %h/.ssh/authorized_keys

ändern in

AuthorizedKeysFile     %h/.ssh/authorized_keys

Also die Datei bearbeiten und vom sshd neu einlesen lassen:

# nano /etc/ssh/sshd_config 
MyBookLive:/# /etc/init.d/ssh reload

Und es funktioniert immer noch kein Einloggen ohne Passwort.

Deshalb als root auf mybooklive einloggen und die Meldungen aus /var/log/sshd.log anzeigen:

# egrep -i 'ssh.*wnf' /var/log/sshd.log
May  3 15:02:59 MyBookLive sshd[7320]: Authentication refused: bad ownership or modes for directory /shares/wnf
May  3 15:02:59 MyBookLive sshd[7320]: Authentication refused: bad ownership or modes for directory /shares/wnf

Kontrolle wer das Homeverzeichnis besitzt:

# ls -l /shares/   
drwxr-xr-x 17 nobody share 65536 Aug 26  2013 wnf
# chown wnf:share /shares/wnf
# ls -l /shares/
drwxr-xr-x 17 wnf    share 65536 Aug 26  2013 wnf

Und siehe da es funktioniert der passwort-lose zugriff auf mein NAS MyBookLive wieder.


Neuer Rechner neues Glück.

Das anmelden per ssh funktioniert nur per Passwort-Authentifizierung.

$ ssh-copy-id -i ~/.ssh/id_rsa.pub bine@mybooklive
Warning: the RSA host key for 'mybooklive' differs from the key for the IP address '192.168.1.6'                              
Offending key for IP in /home/bine/.ssh/known_hosts:3
Matching host key in /home/bine/.ssh/known_hosts:5
Are you sure you want to continue connecting (yes/no)? yes
bine@mybooklive's password: 
sh: line 2: .ssh/authorized_keys: Keine Berechtigung

Login auf MyBookLive und dort die .ssh/authorized_keys löschen

rm .ssh/authorized_keys

wieder ausloggen und den Schlüssel erneut übertragen:

$ ssh-copy-id -i ~/.ssh/id_rsa.pub bine@mybooklive
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
bine@mybooklive's password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'bine@mybooklive'"
and check to make sure that only the key(s) you wanted were added.

$ ssh mybooklive
Tags: Linux-Scripte MyBookLive ssh

scantopdf.pl

11.04.2011 - Lesezeit: ~1 Minute

Mit diesem Script kann ich von meinem Scanner aus eine PDF-Datei im Verzeichnis ~/PDF erzeugen. (Das Original stammt von www.svenna.de))

~~~ #!/usr/bin/perl ###################################################### # LIZENZ # # dieses programm steht unter der bierlizenz! # du kannst es benutzen, veraender und kopieren, wie du willst. # wenn wir uns mal treffen und du meinst es ist es wert - gib mir n bier aus :-) # svenna # # scripts@svenna.de # www.svenna.de ###################################################### # scanner erkennen # dazu muss sane installiert sein $scanner = `scanimage -L`; # drucker erkennen $printer = `lpq -P PDF`; $printer = $1; if ($scanner =~ /(\w+:libusb:\d{3}:\d{3})/){ $scanner = $1; print "Scanner: $scanner\n"; print "Drucker: $printer\n\n"; copy(); } else {print "Immer erst den Scanner anschliessen ;-) \n";} sub copy { print "scanne Dokument\n"; system("/usr/bin/scanimage -d $scanner --gray=yes --resolution 150 -x 210 -y 295 > /tmp/kopie.pbm"); print "wandle in PS-Datei um\n"; # dazu muss netpbm installiert sein system("/usr/bin/pnmtops -equalpixels -dpi 150 -width 8 -height 11.6 /tmp/kopie.pbm > /tmp/kopie.ps"); print "schicke Kopie an Drucker\n"; system("/usr/bin/lpr -P$printer /tmp/kopie.ps"); print "Kopie wurde im Ordner ~/PDF erstellt\n"; } ~~~ Tags: cups scanner Linux-Scripte