Tag: linux
Diable password ssh logins
If you want to disable root from being able to login via ssh edit /etc/ssh/sshd_config and find PermitRootLogin. Change the value to no.
# Authentication:
LoginGraceTime 120
PermitRootLogin no
StrictModes yes
If you wish to disable all password logins which requires uses to use public keys instead in /etc/ssh/sshd_config and find PasswordAuthentication. Change the value to no.
PasswordAuthentication yes
If you wish to diable password logins for only some users add the following to your /etc/ssh/sshd_config file
Match User user1, user2, user3 PasswordAuthentication no
Snapshot your /etc directory
Use git to snapshot your /etc directory
http://www.jukie.net/~bart/blog/20070312134706
Or use mercurial to snapshot your /etc directory
http://michael-prokop.at/blog/2007/03/14/maintain-etc-with-mercurial-on-debian/
Encrypting a directory with Ubuntu
I found a nice post on the ubuntu forums on how to encrypt a directory in Ubuntu. This is a copy and paste of that post by remmelt, I cannot take credit for it.
This guide describes how to create encrypted directories. These can come in handy for laptop users, password lists and the like.
1. Install the software
Code:
sudo apt-get install encfs fuse-utils
sudo modprobe fuse
And since we don’t want to modprobe each time we reboot, add “fuse” to /etc/modules (without quotes, on a line of its own)
2. Add yourself to the fuse group
The installer creates a fuse group and to use fusermount you need to be in this group. You can do this with your favourite GUI admin tool or command line:
Code:
sudo adduser fuse
3. Create a directory where your encrypted stuff will be stored
I put mine in my home dir, but you can put it anywhere you like.
Code:
mkdir ~/encrypted
4. Create a mountpoint
This is the directory where you will mount the encrypted directory. Through this path you can access the encrypted files.
Code:
mkdir ~/temp_encr
5. Create the encrypted system and mount it
The first time you try to mount the directory, encfs will create the encrypted filesystem. It works like the regular mount:
Code:
encfs
So for this example:
Code:
encfs /home//encrypted /home//temp_encr
Note that encfs wants absolute paths, i.e. starting with a /
6. Do the work
Put some files in your ~/temp_encr folder and look in the ~/encrypted one: they will show up there, encrypted.
7. Unmount the encrypted filesystem
Unmounting is as easy as
Code:
fusermount -u /home//temp_encr
8. Goto step 5
Repeat! EncFS will only create the filesystem once, after that first time it will ask for a password and mount your directory.
Remember to keep the two directories apart: in this example the “encrypted” folder holds your encrypted data and should not be used directly. The gateway to access this data is “temp_encr” or whatever you want to call it.
This was tested and verified on Ubuntu 10.04
Eclipse 3.5 Wizard Buttons Do Not Work with GTK2 2.1.8
The wizard buttons in Eclipse 3.5 Galileo do not work with gtk2 2.18. You can get around it by pressing the Enter key, but that’s still a pain.
The solution is to create a file that starts eclipse with GDK_NATIVE_WINDOWS=1
Example, create a file starteclipse with the following contents:
#!/bin/sh
export GDK_NATIVE_WINDOWS=1
/opt/eclipse/eclipse
scp a path with spaces
I find the easiset way to scp a path with spaces is like so:
scp username@host:”‘/this/is my path/with spaces/and this is my file.txt'” ./
Note the double quotes followed by a single qoute ( ” ‘ text ‘ “), and closed in reverse order. Your shell will ignore the double qoute and the remote shell will receive the single qoutes.
You can also escape it, but that’s kind of a pain. example:
scp username@host:/this/is\\ my\\ path/with\\ spaces/and\\ this\\ is\\ my\\ file.txt ./
My preferences is obvious.
Enable a Swap File in Linux
You can use a Swap File instead of a Swap Partition with the linux kernel 2.6. Yeah, old news, but I’ve still always used a partition out of habit. Time to change that habit!
1. Log in as root, or use sudo
2. Type following command to create 512MB swap file
sudo dd if=/dev/zero of=/swap.img bs=1024k count=512 could also do it this way (1024 * 512MB = 524288 block size) sudo dd if=/dev/zero of=/swap.img bs=1024 count=5242883. Format it as swap. sudo mkswap /swap.img4. Activate your swap file immediately sudo swapon /swap.img
5. Optional, but I recommend activating the swap file on boot. Edit your /etc/fstab file and add the following:/swap.img none swap sw 0 0
6. To verify that the swap is working type:free -m
Links this information was taken from:
http://blog.mypapit.net/2007/07/how-to-add-linux-swap-file-if-you-dont-have-swap-partition.html
http://www.cyberciti.biz/faq/linux-add-a-swap-file-howto/
Convert Avi to MP4 h.264 for Ipod
ffmpeg -i xyz.avi -acodec libfaac -ab 128k -s 320x176 -vcodec libx264 -b 400kb -threads 2 xyz.mp4
from this link
scp a file with spaces
How annoying…. scp a file with spaces. example below:
scp username@servername:”/your/path\\ with\\ spaces” ./
Convert FLAC to ALAC
If you have a ipod you know it can’t play FLAC files. If you still want lossless quality music you’ll have to convert it to ALAC. This can be done very easily with ffmpeg. Here is how to do it:
ffmpeg -i input_flac_file -acodec alac outputfile.m4a
Here is a script to convert all flac files in a directory to alac.
#!/bin/bash
#get all flac files in a directory
#loop over all files
#get file name without extention
#run it through ffmpeg with the output file as the filename.m4a
for file in *flac
do
basename=`basename "$file" .flac`
ffmpeg -i "$file" -acodec alac "$basename".m4a;
done