BSD is a little paranoid about where your passwords come from, so they'll insist on getting it from a stream. Here's an example:
(edit the file '/tmp/pass' and deposit the password there) % su root -c sh Password: # pw useradd -n test -c "Test User" -m -h 3 3< /tmp/pass # grep test /etc/master.passwd test:$1$T2tu0BET$UGPrNB1FavzjlzhTwUWRN.:1002:1002::0:0:Test User:/home/test:/bin/sh # exit % su test Password: [typed "foobar" here...] $ exit
bsdcommandsfreebsdneatparanoidpasswordspwsecurity
Ever been on a machine that was ailing and just wouldn't respond? As soon as you're root, lower the priority of the offending process ID(s) (in this example, 1103) by using the 'renice' command:
# renice -19 1103
commandsconfigurationcontroldebuggingmonitoringpriorityprocessrecoveryrenicerescuesecurityshell
Tired of typing your SSL password on boot of your webserver? You can decrypt it if you're certain it's safe:
# openssl rsa -in server.key -out server.key.unsecure
apachebootcommandsencryptionkeyopensslsecurityshellsslwebserver
Use these commands to generate a self-signed SSL certificate (e.g. for Apache):
# openssl genrsa 1024 > server.key # openssl req -new -key server.key -x509 -days 90 -out server.crt
apachecertificatescommandskeysopensslsecurityssl
Use the apg utility to generate strong mnemonic passwords:
$ apg -st Please enter some random data (only first 8 are significant) (eg. your old password):> Coydgoceuk6 (Coyd-goc-euk-SIX) Caculpyep7 (Cac-ulp-yep-SEVEN) otevDet6 (ot-ev-Det-SIX) Jiwacwarj6 (Ji-wac-warj-SIX) gurkOnRyet1 (gurk-On-Ryet-ONE) EbTarIv0 (Eb-Tar-Iv-ZERO)
apgcommandsgeneratemnemonicneatpasswordsecurityutilities
If you need to move files, logs, or any kind of program output off a compromised system without disrupting evidentiary data on the disk, use netcat.
On your trusted system:
$ nc -v -l -p 2222 > victim.dump
On the victim's system:
$ <program> | nc <trusted_system> 2222
Where program is the discovery application you're running (e.g. netstat -an).
cleanupcommandsforensicsncnetcatparanoidsecuritytroubleshooting
If you want to open an SSH tunnel in the background, use the -N and -f switches:
ssh -Nf -L2121:localhost:21 user@host
authenticationencryptionsecurityshellsshtunnel
If you want to use tcpdump to watch initiating connections (that is, the syn flag only is set indicating we're looking at the first third of the three-way handshake) on ports 80 and 443 you could do something like this:
# tcpdump '(tcp[13] & 0x3f = 2) and (dst port 80 or dst port 443)'
commandsconnectionsmonitoringnetworksecurityshelltcpdump