пятница, 28 мая 2010 г.

SSH tunnelling

Сначала своими словами. Простой пример. Необходимо зайти на веб сервер по шифрованому соединению... ну или воспользоваться любой другой службой этого сервера секьюрно. Там стоит sshd.



На машине клиенте ssh -L 1234:localhost:80 om@192.168.1.1. Это означает, что с 1234 порта ip адреса 127.0.0.1 пакет будет перенаправлен на адрес 192.168.1.1 порт 80 внутри SSH трубы. Для проверки вбейте в адресной строке браузера http://localhost:1234.

Далее оригинал статьи. http://www.brandonhutchinson.com/ssh_tunnelling.html



ssh tunnelling is an excellent way to tunnel insecure protocols through a secure communication channel. In this example, I'll tunnel POP3 traffic using ssh. Traditional POP3 traffic, including username and password information, travels clear-text across the network.

OpenSSH is used in the following examples.

To tunnel POP3 traffic using ssh:

1. Make sure an ssh client is installed on your machine and an ssh server is installed on the POP3 server.

2. Create a local ssh tunnel on your machine (port 1234 for this example) to the POP3 server's port 110. You will need to be the root user to bind to "privileged" ports (< 1024).
# ssh -f -N -L 1234:localhost:110 user@POP3_server

3. Test the tunnel.
$ telnet localhost 1234
You should see the POP3 server's banner information.

4. Configure your mail client to access your mail via POP3 using mail server localhost and port 1234.

"Reverse" ssh tunnel
It is possible to create a "reverse" ssh tunnel. The reverse tunnel will allow you to create an ssh tunnel from your work computer to your home computer, for example, and then login to your work machine from your home machine even if your work firewall does not permit ssh traffic initiated from your home machine!

For this to work, an ssh server must be installed on your work and home computer, and ssh (TCP port 22) must be allowed outbound from your work computer to your home computer.

$ ssh -R remote_port:localhost:22 your_home_computer

ex. $ ssh -R 2048:localhost:22 home.computer.com

At home, you would then run ssh -p 2048 localhost to log into your work computer via ssh.

Маршрутизация в Solaris 10 без reboot.

Enable/Disable IP Forwarding in Solaris 10 without reboot
April 24, 2008 · Filed Under Networking, Solaris 10


IP packet forwarding is the process of routing packets between network interfaces on one system. A packet arriving on one network interface and addressed to a host on a different network is forwarded to the appropriate interface.

In Solaris 10, IP Forwarding can be enabled or disabled using the routeadm & ifconfig commands as against the ndd commands in Solaris 9 and earlier. The advantage is the change dynamic and real-time and the change persist across reboot unlike the ndd command.

Enable/Disable IP Forwarding globally

To globally enable IP Forwarding in Solaris 10 use the routeadm command as follows:

In IPv4

solaris10# routeadm -e ipv4-forwarding

In IPv6

solaris10# routeadm -e ipv6-forwarding

The switches “-e” enables IP Forwarding.

To disable IP Forwarding

In IPv4

solaris10# routeadm -d ipv4-forwarding

In IPv6

solaris10# routeadm -d ipv6-forwarding

The switches “-d” enables IP Forwarding.

After the change run the following command for the changes to take effect.

solaris10# routeadm -u

Enable/Disable IP Forwarding per interface

To enable IP Forwarding on a specific interface (say ce0) using the ifconfig command

In IPv4

solaris10# ifconfig ce0 router

In IPv6

solaris10# ifconfig ce0 inet6 router

To disable IP Forwarding for an interface (say ce0)

In IPv4

solaris10# ifconfig ce0 -router

In IPv6

solaris10# ifconfig ce0 inet6 -router

Взял тут
http://www.sunsolarisadmin.com/solaris-10/enabledisable-ip-forwarding-in-solaris-10-without-reboot/

среда, 28 апреля 2010 г.

Serial Console on Sun Servers

Есть у меня кластер. В нём стоят два v445. К каждому подключен Storage. От serial B сервера до serial A storage идёт консольный кабель. Я задался вопросом "Как из под солярки выйти на СериалБ". Нагуглил классную статейеку.

http://www.softpanorama.org/Solaris/Startup_and_shutdown/serial_console_on_solaris.shtml

First of all you need null model cable. Specialists of old school can solder their own but this art is essentially lost :-).

Sun server usually come with one crossover 9-pin connector (silver colored -- Sun Part No. 530-3100-01). Don't throw it out when you get with the server ;-). This connector can be used with a regular Ethernet cable. That's the most convenient solution for server rooms as you can use cable of any necessary length to position your laptop conveniently or get to the desktop or workstation (if connecting to a Sun workstation or server, use 25 pin connector --- Sun Part No. 530-2889-03 or equivalent). You can also create you own or buy equivalent or use ready made cable used for managing network devices like Cisco.

V210 and V240 have two management port: one serial management (marked SER MGT) and one Net management ( marked NET MGT). You need to use serial management port. Net management port is used to connect to ALOM and you need to configure it before that.

There are two typical way to use serial console for connecting to Sun servers, for example, V210 and V240.

* Use Windows laptop with some Windows emulator (Hyperterminal, Teraterm, etc).
* Use Sun terminal emulator (tip), in Windows SFU or nearby Sun machine or if you have a laptop with Solaris installed.

No keyboard should be connected to the server/workstation on which you plan to use serial console. Sun machines on power-up check the presence of the keyboard. If something is plugged in, they assume the console input device is the keyboard. If it doesn't see any keyboard, it redirects console input/output to serial port "A".

Whether or not the Sun server has a videocard ("framebuffer" card) installed is irrelevant. Some Sun workstations have a framebuffer built in. That's why the test is always done for the keyboard presence.

Do not connect a keyboard to the Sun machine if you want to use serial console

If you SHUT OFF YOUR TERMINAL, while it is connected to a running Sun machine, you send a "break" signal via the serial line and the Sun will jump back into the OK prompt, halting the OS. This can cause considerable confusion.
Using Window Hyperterminal

Note: you can upgrade to free version 6.3 (non-commercial use)

Try these COM1 port settings:

* Bits per second: 9600
* Data bits: 8
* Parity: None
* Stop bits: 1
* Flow Control: None

I'm going to use a Dell C600 laptop an an example. The laptop has a 9pin serial port at the back that corresponds to Serial port 1 (SER 1). In other cases you need first to verify that you're "speaking" to the correct port (you can do this using for example serial mouse and disconnecting your current mouse).

Using windows terminal you can use VT-100 or better.

You can connect to Sun server that has no keyboard or display attached anytime. sometimes you need to press enter one of two times to see the output. You can disconnect anytime by disconnecting cable (do not close you terminal).
Using Tip

Note: tip is available in SFU and Solaris /etc/remote can be used with it. Connect the appropriate serial cable from serial port on laptop (usually serial port 1) to serial port A on target Sun system.

Use "tip hardwire" (not "hardware") to open a connection to the headless box before booting it: From a Solaris shell prompt on the local system, issue the command:

tip hardwire

OR

tip ser1

Notes

* This is "tip hardwire" (not "tip hardware").
* ser1 should be defined in /etc/remote (see below)

hardwire is defined on Solaris in the /etc/remote to use port B (for laptop you need to correct this or add another line, see below):

cuab:dv=/dev/cua/b:br#2400
dialup1|Dial-up system:\
:pn=2015551212:tc=UNIX-2400:
hardwire:\
:dv=/dev/term/b:br#9600:el=^C^S^Q^U^D:ie=%$:oe=^D:
tip300:tc=UNIX-300:
tip1200:tc=UNIX-1200:
tip0|tip2400:tc=UNIX-2400:
tip9600:tc=UNIX-9600:
tip19200:tc=UNIX-19200:
UNIX-300:\

If you need to connect from serial port A you need to modify this entry in /etc/remote or better add another entry, for example ser1 :

ser1:\
:dv=/dev/term/a:br#9600:el=^C^S^Q^U^D:ie=%$:oe=^D:

After tip session established you can boot the server. This tip session should be kept active as long as server remains online.
You should be connected. Press enter a few times to see if you are getting a response. If you are not, check your connections and make sure you have the right cable.

From within tip, you can access a tip menu by pressing ~? after a carriage return. To quit the tip session, press ~. and to send a break character, type ~#

To send a break character, type ~#


The hardwire parameter in the tip command refers to an entry in the file /etc/remote which describes the serial port connections. By default, hardwire specifies port B with 9600 baud, 8 data bits, no stop bits, and 1 parity bit. Connect, via a null modem, serial port "A" of the Sun to your terminal's serial port. Your terminal settings should be 9600 8N1, which are the default serial settings of the Sun.

If you use tip, if possible, emulate a SUNTERM.


Behavior of the Serial Console

Now, depending upon the machine you have, and the revision of your PROM, you'll either be greeted by a ">" prompt or an "ok" prompt. Machines that have everything configured properly and a working OS will of course, begin to boot by themselves rather than displaying a prompt.

If you want to stop the boot from happening so you can wipe out the OS to install something else (or just perform maintenence) or make changes to the NVRAM, then, before the OS starts to load from the HD, (essentially, right after it tells you the hardware ethernet address, but before it says "boot device"), you need to send a "break" signal.

* On a PC, this is done by holding down the CTRL key and tapping the "Break" key (Pause/Break on most PC keyboards).
*

tip sends break via "~#"

Once you've sent a break, as above, you'll be greeted by "OK" prompt (FORTH interpreter prompt).

вторник, 20 апреля 2010 г.

SUN Solaris ALOM

Вот нашел письмо от одного очень крутого чела... можно сказать паладина святого ордена, старейшего эриксоновского инженера по пакетной передачи данных в России. :) Собственно, содержание:

Hello colleagues,

Please see the steps that needs to be done in order to arrange remote access to SASN from MM. IP addresses used below are the fake ones. Please update instruction for each region.

1. Connect SASN Ethernet ALOM port to the switch where VLAN serving MM is available. Alternatively if there is a lack of ports on the switch but there is spare interface on MM you can connect SASN Ethernet ALOM and MM directly. In the latter case you can just use IP addresses from example...
2. Connect PC RS-232 port with Serial DB9-RJ45 cable to the SASN Serial ALOM port. Start Terminal program on PC with standard settings (9600, 8N1)
3. Connect power cables to the SASN. After that ALOM will be started. You should see login prompt in a while.
4. Login to the SASN ALOM. User: root. Password: changeme
5. Configure SASN ALOM Remote management via network:
-> cd /SP/network
-> set pendingipaddress=10.10.10.10
-> set pendingipnetmask=255.255.255.0
-> set pendingipgateway=10.10.10.1
-> set pendingipdiscovery=static
-> set commitpending=true
6. Verify network configuration:
-> show /SP/network
7. Login to MM and try ssh to SASN ALOM IP
ssh root@10.10.10.10 (password changeme)

Please let me know if you have any questions regarding this procedure.

BR/ Nickolay

Прочитал я в очередной раз. Эх, думаю, "освежу ка я в памяти процедуру". Зашел на терминальник, в порт, куда подключена, ещё не нагруженная, двести сороковая netra последовательным портом. Консоль. Набираю заветные "#." (решетка-точка) для входа в ALOM.

Copyright 2007 Sun Microsystems, Inc. All rights reserved.
Use is subject to license terms.


Sun(tm) Advanced Lights Out Manager 1.6.7 (radius2-rnd)

Please login:

Набираю указанные выше заветные default login/password и.. не пускает. Перебрал всё что помнил - нет. И вот вопрос. Что делать дальше? Вот об этом я и решил написать. Есть замечательная команда scadm.

USAGE: scadm [options]
For a list of commands, type "scadm help"

scadm - COMMANDS SUPPORTED
help, date, set, show, resetrsc, download, send_event, modem_setup,
useradd, userdel, usershow, userpassword, userperm, shownetwork,
loghistory, version

scadm - COMMAND DETAILS
scadm help => this message
scadm date [-s] | [[mmdd]HHMM | mmddHHMM[cc]yy][.SS] => print or set date
scadm set => set variable to value
scadm show [variable] => show variable(s)
scadm resetrsc [-s] => reset SC (-s soft reset)
scadm download [boot] => program firmware or [boot] monitor
scadm send_event [-c] "message" => send message as event (-c CRITICAL)
scadm modem_setup => connect to modem port
scadm useradd => add SC user account
scadm userdel => delete SC user account
scadm usershow [username] => show user details
scadm userpassword => set user password
scadm userperm [cuar] => set user permissions
scadm shownetwork => show network configuration
scadm loghistory => show SC event log
scadm version [-v] => show SC version (-v verbose)

Вот, собственно, и всё.

root@radius2-rnd # scadm usershow

username permissions password
-------- ----------- --------
admin cuar Assigned

И следующая команда, конечно же, scadm userpassword => set user password.

Просмотрим, что вообще настроено.

root@radius2-rnd # scadm show
if_network="true"
if_modem="false"
if_connection="telnet"
if_emailalerts="false"
sys_autorestart="xir"
sys_bootrestart="none"
sys_bootfailrecovery="none"
sys_maxbootfail="3"
sys_xirtimeout="900"
sys_boottimeout="120"
sys_wdttimeout="60"
netsc_tpelinktest="true"
netsc_dhcp="false"
netsc_ipaddr="0.0.0.0"
netsc_ipnetmask="255.255.255.0"
netsc_ipgateway="0.0.0.0"
mgt_mailhost=""
mgt_mailalert=""
sc_customerinfo=""
sc_escapechars="#."
sc_powerondelay="false"
sc_powerstatememory="false"
sc_clipasswdecho="true"
sc_cliprompt="sc"
sc_clitimeout="0"
sc_clieventlevel="2"
sc_backupuserdata="true"
sys_eventlevel="2"

Все эти параметры можно поменять из консоли и из терминала (из под root).

вторник, 16 марта 2010 г.

java script redirect

Уже постил в блоге php redirect. Вот тоже самое на java script.


script language=javascript window.location="http://172.26.18.179/cgi-bin/sgsn2_eqtrunk.pl";

script

вторник, 9 марта 2010 г.

MYSQL user management

Нашёл в своих доках две полезные заметки по MYSQL.

Сброс пароля пользователя root в mysql.

Наша память, к сожалению, нас иногда подводит. И мы никак не можем вспомнить железно, как нам кажется, отпечатанный в памяти пароль. Вы можете сказать, что нужно иметь записную книжку а лучше две, и конечно будете правы. Но… Тем не менее иногда все-таки возникает необходимость восстановления забытого, либо утраченного пароля. Сегодня я опишу простой метод восстановления пароля суперпользователя root для базы данных mysql.

Для этого необходимо выполнить всего несколько шагов.
1. Останавливаем mysql.
service mysqld stop
2. Запускаем mysql следующей командой:

/usr/bin/mysqld_safe --skip-grant-tables --user=root &

3. Запускаем клиента mysql
mysql -u root
4. Выполняем sql запрос
UPDATE mysql.user SET Password=PASSWORD(’newpwd’) WHERE User=’root’;
где newpwd – новый пароль.
5. Применяем изменения
FLUSH PRIVILEGES;
6. Выходим из mysql клиента выполнив в нем команду exit
7. Перегружаем mysql сервер.
service mysqld restart

Ну и все на этом. Пароль суперпользователя root для базы данных mysql изменен. Добавлю, что конечно же этот метод описан в официальном руководстве по mysql, но может кому пригодится.

Оригинал: http://dedicatesupport.com/archives/30

И вторая:

Как создать пользователя mysql через cli

Небольшой пост о том, как создавать из командной строки mysql новую базу данных и нового пользователя mysql с полными правами на только что созданную базу.
mysql -uroot -p CREATE DATABASE ; GRANT ALL PRIVILEGES ON .* TO 'my_user'@'localhost' IDENTIFIED BY 'my_password' WITH GRANT OPTION;

Для того чтобы выставить новому пользователю полные права на все базы данных используем следующую команду:
GRANT ALL PRIVILEGES ON *.* TO 'my_user'@'localhost' IDENTIFIED BY 'my_password' WITH GRANT OPTION;

Доступ к базе для данного пользователя возможен только с localhost. Если вы хотите дать ему доступ к базе с любого хоста, используете % вместо localhost:
GRANT ALL PRIVILEGES ON .* TO 'my_user'@'%' IDENTIFIED BY 'my_password' WITH GRANT OPTION;