Showing posts with label shell. Show all posts
Showing posts with label shell. Show all posts

Sunday, April 7, 2013

Linux adduser user@domain.tld with @ or . inside the userid and use it as an FTP account





If you want to add a new user to your linux box and it not contains any special char like an '@' or '.' there is no problem. In the other case you could not find an answer simply googling around. For this reason i have to make some tests on different kind of server (dedicated and vps ones). 

Via plesk or others gui i didn't find a way to add user with special chars inside the username, also via shell i had some problems with that. 

The final solution for me was using webmin or follow the instructions below:

# groupadd ftpusers
# adduser 1234455 -d /home/1234455 -G ftpusers
# passwd 1234455
# type and retype password
# chown 1234455:ftpusers /home/1234455/

Well, now you have a user without @extdomain.tld so to do that you have to modify two files:

/etc/passwd
/etc/shadow

edit in passwd:

old one
1234455:x:10005:505::/home/1234455:/bin/false
new one
1234455@extdomain.tld:x:10005:505::/home/1234455:/bin/false

edit the same in the shadow and be carefull when do that.

After doing these hacks you could access to your home directory via ftp using 1234455@extdomain.tld :)








Read more...

Wednesday, May 5, 2010

Add a custom script as a daemon on reboot of a redhat centos server


To enable a custom script in a redhat centos server linux box you have to follow those simple steps.
This is useful when you have to start a server process that don't return anything..
One example is openoffice server aka (soffice).
Suppose you have two files.
The first file A call the second file named B-so
The file A contains a code like this

# Source function library.
. /etc/rc.d/init.d/functions

[ -f /usr/local/sbin/B-so ] || exit 0


prog="B-so"
start() {
echo -n $"Starting $prog: "
daemon /usr/local/sbin/B-so 1> /dev/null 2> /dev/null &
RETVAL=$?
echo
return $RETVAL
}

stop() {
if test "x`ps aux | grep B-so | grep -v grep | awk '{ print $2 }'`" != x; then
echo -n $"Stopping $prog: "
killproc B-so
killall processname
echo
fi
RETVAL=$?
return $RETVAL
}

case "$1" in
start)
start
;;

stop)
stop
;;

status)
status B-so
;;

restart)
stop
start
;;

*)
echo $"Usage: $0 {start|stop|restart|status}"
exit 1

esac

exit $RETVAL


Copy the file A in the directory /etc/init.d/

Copy the second file B.so in the dir /usr/local/sbin/
The file B-so contains a code like this:


. /etc/rc.d/init.d/functions

LOG="/root/mail2fax/log/safe-B.log"


while :
do
...done some stuff ...
done



After that you have to add a line with the path to the service to start in the /etc/rc.local.

Check if permissions on those two files are set on 0755,then you could reboot your server and verify if the service start successfully.


img credits wmliu



Read more...