Archive

Posts Tagged ‘sysadmin’

Monitorização activa de filesystem

November 17th, 2009 roger 2 comments

Foi-me solicitado para monitorizar um determinado filesystem e que ao atingir uma determinado valor de ocupação deveria ser chamado um script externo.  elaborei o seguinte script que deixo aqui para referência futura :P

#!/bin/ksh
#Data Actual
date=$( date )
#utilizacao de disco

fschk=$(bdf /arc | grep /arc | grep -v vg | awk ‘{ print $4} ‘ | sed ’s/%//’)

#confirma se bd ja esta a ser tratada
rman=$(ps -elf | grep rman | grep -v grep | wc -l)

#
if [ $fschk -ge 50 ] ; then
if [ $rman -gt 0 ] ; then
echo “$date $fschk % processo rman esta a correr” >> logmonfs

else

echo “$date $fschk % inicializando o script xpto.sh” >> logmonfs
sh -x xpto.sh
fi
else
echo “$date filesystem /arc ocupa $fschk % ” >> logmonfs
fi
Categories: scripts, sysadmin Tags: , ,

sftp sem acesso a shell

November 5th, 2009 roger No comments

Como criar um user para aceder ao sftp mas sem acesso a shell por ssh?

Simples adiciona-se o user e altera-se a seguinte linha no /etc/passwd

de:

user:x:999:999::/home/user/./:/bin/bash

Para:

user:x:999:999::/home/user/./:/usr/libexec/openssh/sftp-server

Categories: sysadmin Tags:

pwconf

October 7th, 2009 roger No comments

Em alguns sistemas  unix podemos ainda encontrar a hash da password no ficheiro /etc/passwd

Para passar as password para o ficheiro /etc/shadow usa-se a seguinte ferramenta de sistema pwconf:

PWCONV(8)			  26 Sep 1997			     PWCONV(8)

NAME

pwconv, pwunconv, grpconv, grpunconv - convert to and from shadow passwords and groups.

SYNOPSIS

pwconv pwunconv grpconv grpunconv

DESCRIPTION

pwconv creates shadow from passwd and an optionally existing shadow. pwunconv creates passwd from passwd and shadow and then removes shadow. grpconv creates gshadow from group and an optionally existing gshadow. grpunconv creates group from group and gshadow and then removes gshadow. These four programs all operate on the normal and shadow password and group files: /etc/passwd, /etc/group, /etc/shadow, and /etc/gshadow. Each program acquires the necessary locks before conversion. pwconv and grpconv are similar. First, entries in the shadowed file which don't exist in the main file are removed. Then, shadowed entries which don't have `x' as the password in the main file are updated. Any missing shadowed entries are added. Finally, passwords in the main file are replaced with `x'. These programs can be used for initial conversion as well to update the shadowed file if the main file is edited by hand. pwconv will use the values of PASS_MIN_DAYS, PASS_MAX_DAYS, and PASS_WARN_AGE from /etc/login.defs when adding new entries to /etc/shadow. Likewise pwunconv and grpunconv are similar. Passwords in the main file are updated from the shadowed file. Entries which exist in the main file but not in the shadowed file are left alone. Finally, the shadowed file is removed. Some password aging information is lost by pwunconv. It will convert what it can.

BUGS

Errors in the password or group files (such as invalid or duplicate entries) may cause these programs to loop forever or fail in other strange ways. Please run pwck and grpck to correct any such errors before converting to or from shadow passwords or groups.

FILES

/etc/login.defs shadow password suite configuration

SEE ALSO

grpck(8), login.defs(5), pwck(8).
Categories: sysadmin Tags:

SSH Manager

September 25th, 2009 roger No comments

Normalmente uso o putty para ligações ssh senti a falta de algo do género para linux mas em modo texto com alguma pesquisa descobri o seguinte programa  sshmgr deixo aqui a referencia ao programa :)

SSH ManaGeR is now deprecated in favour of CONNection ManaGeR.

If you have many ssh accounts on different servers requiring different ports and user names, this is the tool for you!
This is more than _just_ a simple ssh wrapper, sshmgr is really seven applications in one!
There is sshmgr, scmdmgr, sftpmgr, scpget, scpput, ftpmgr and telnetmgr.

sshmgr depends on Perl (>= 5.6.0) and the CPAN module AppConfig. sshmgr also has an accompanying Bash (requires bash >= 2.05b) script for extending the tab auto completion for the commands sshmgr, scmdmgr, sftpmgr, ftpmgr and telnetmgr. There is now a Makefile included for all those that don’t want the hassles of the deb, rpm or tgz packages. Please don’t ask me to include password storing facilities, use ssh-agent and ssh keys to alleviate any password typing woes. Documentation on ssh-agent and ssh keys can be found here.

If you want to contribute bug-reports, feature requests, or code you can join the mailing list here or you can contact me directly.

Here’s my PGP Key.
PGP key num: 04A112AD
Fingerprint: 0864 D1CC E3E5 48BF 3B0F 4373 55EC C529 04A1 12AD

Categories: scripts, sysadmin Tags: ,

Pstools

September 2nd, 2009 roger No comments

Por vezes tenho de dar algum tipo de assistência em maquinas Microsoft (infelizmente).

Recentemente voltei a descobrir e utilizar um conjunto de ferramentas que permitem executar alguns comandos unix style, o que aconselho vivamente.

The Windows NT and Windows 2000 Resource Kits come with a number of command-line tools that help you administer your Windows NT/2K systems. Over time, I’ve grown a collection of similar tools, including some not included in the Resource Kits. What sets these tools apart is that they all allow you to manage remote systems as well as the local one. The first tool in the suite was PsList, a tool that lets you view detailed information about processes, and the suite is continually growing. The “Ps” prefix in PsList relates to the fact that the standard UNIX process listing command-line tool is named “ps”, so I’ve adopted this prefix for all the tools in order to tie them together into a suite of tools named PsTools.

Note: some anti-virus scanners report that one or more of the tools are infected with a “remote admin” virus. None of the PsTools contain viruses, but they have been used by viruses, which is why they trigger virus notifications.

The tools included in the PsTools suite, which are downloadable as a package, are:

  • PsExec – execute processes remotely
  • PsFile – shows files opened remotely
  • PsGetSid – display the SID of a computer or a user
  • PsInfo – list information about a system
  • PsKill – kill processes by name or process ID
  • PsList – list detailed information about processes
  • PsLoggedOn – see who’s logged on locally and via resource sharing (full source is included)
  • PsLogList – dump event log records
  • PsPasswd – changes account passwords
  • PsService – view and control services
  • PsShutdown – shuts down and optionally reboots a computer
  • PsSuspend – suspends processes
  • PsUptime – shows you how long a system has been running since its last reboot (PsUptime’s functionality has been incorporated into PsInfo)

The PsTools download package includes an HTML help file with complete usage information for all the tools.

Experimentem.

Categories: sysadmin Tags: