PTY allocation request failed on channel 0 [ssh|CentOS]

OpenVZやXen等のVPSでは掲題の問題が発生することがある。
原因は様々だがOpenVZやXenで発生する人が多い模様。

私の場合はOpenVZの環境で発生した。
ある日自分のblogを見てみると「データベースにアクセス出来ません」とエラーが出て表示されなくなっている。
mysqldが死んだかと思いVPSにログインすると

PTY allocation request failed on channel 0

上記のエラーが出てssh経由は何も出来ない悲惨な状態。
私の場合はどうやらCentOSのupdateで発生した模様。

以下のURLを見て解決策が分かったのはいいものの、
http://www.asteriosk.gr/blog/2009/02/20/pty-allocation-request-failed-on-channel-0/

ssh接続出来ないのでホスティングの管理画面からサポートに連絡。
私はNYNOCというホスティングを使っており、HyperVMという管理画面があります。
すると「Fix Centos Dev」という実行ボタンがあるからそれを使えと指示される。
実行するとあっさり解決。この機能が管理画面に組み込まれているってこと自体そんなに発生するのだろうか。

やっとssh接続できるようになったのでmysqldをrestartしようとするも、立ち上がらず。

ログを見てみると権限のようです。

/var/lib/mysqlの中のファイル所有者と/var/run/mysqldの権限が違う模様。

まったく心当たりがありませんが、NYNOCにしてから謎の問題が多発。。

How to use ftp on Ubuntu (vsftp installation)

When you upload a website, ordinarily you use sftp, but the need to create a restricted user appears, so note that way to make it in ubuntu.

Now as an example, in order to use ftp, we will create a new user called “iwaking”.

Add user.

# useradd iwaking

Setup password.

# passwd iwaking

Set up to refuse users login via ssh, allow only ftp user’s access this time.

# vim /etc/ssh/sshd_config
DenyUsers iwaking

And the ftp server is famous for vsftp, so you will install it.

# yum install vsftpd

Next, setting vsftpd.

# vi /etc/vsftpd/vsftpd.conf

I will describe only the points that have changed.

#Turn off anonymous user
anonymous_enable=NO

#Allow ASCII mode when uploading and downloading
ascii_upload_enable=YES
ascii_download_enable=YES

#Turn on chroot_list, and restrict user scope
chroot_list_enable=YES
chroot_local_user=YES
chroot_list_file=/etc/vsftpd/chroot_list

#Specify a valid user account in the user_list file
userlist_enable=YES
userlist_deny=NO

Next, edit “user_list” file. This is the user permission list.
In this scenario, a user who is given permission is “iwaking”.

# vi /etc/vsftpd/user_list
#root
#bin
#daemon
#adm
#lp
#sync
#shutdown
#halt
#mail
#news
#uucp
#operator
#games
#nobody
iwaking

There is “ftpusers” file which is a rejection list.
In this scenario, it is OK if “iwaking” is not in the list. #

# vi /etc/vsftpd/ftpusers
root
bin
daemon
adm
lp
sync
shutdown
halt
mail
news
uucp
operator
games
nobody

There is “chroot_list” file which is rejection list for chroot.
I do not edit this file as chroot will be done.

start vsftpd

# /etc/init.d/vsftpd restart

Configure them to run with starting up.

# chkconfig --level 345 vsftpd on

Release port 20 and 21, if you are running a firewall.

Try to login from local machine as

# chkconfig --level 345 vsftpd on
# ftp host_name
Name : iwaking
331 Please specify the password.
Password:

If login is successful, then it is done.

Settings of multiple IP address in Proxy server squid

I’m operating proxy server and using squid but I might need multiple IP operation so I’d like to leave a note for that. Multiple IP operation in squid has no information even if it’s in English, so I wrote them just in case for those might be stuck.

First, edit below

vi /etc/squid/squid.conf

And add to port listen

http_port 200.200.200.200:3128 http_port 200.200.200.201:3128

describe acl

acl ip1 myip 200.200.200.200/32 acl ip2 myip 200.200.200.201/32

outgoing address settings

tcp_outgoing_address 200.200.200.200 ip1 tcp_outgoing_address 200.200.200.201 ip2

and, changing dns server settings

dns_nameservers xxx.xxx.xxx.xxx

/etc/init.d/squid restart

That’s all. It’s easy if you know that.

 

PTY allocation request failed on channel 0 [ssh|CentOS]

The subject issue may occur in VPS such as OpenVZ and Xen. The reason is vary but lots of case are happened in OpenVZ and Xen.

In my case, it happened in OpenVZ environment. One day I saw my blog the error said “cannot access to the database.” and nothing display. I thought mysqld dead so I logged in VPS.

PTY allocation request failed on channel 0

Just the error above showed and it’s horrible, I couldn’t do anything. In my case, seems like happened in CentOS update.

Although I found a solution by referring to URL below, http://www.asteriosk.gr/blog/2009/02/20/pty-allocation-request-failed-on-channel-0/

I could not establish ssh access, I contacted the customer support from hosting admin screen. I use NYNOC hosting provider. It has admin screen called “HyperVM”. I was instructed to use “Fix Centos Dev” execution button. On using the button, the access problem was resolved. I was beginning to feel that, perhaps the button was integrated into the admin screen because the problem frequently occurs. Anyhow I re-gain the ssh connection and tried to restart mysqld but it didn’t work.

I checked the log and it seems permission problem.

It showed that the file owner in /var/lib/mysql did not match /var/run/mysqld permission.

I really have no idea why but since I started using NYNOC, I have come across many unknown problems….:(

プロクシサーバーsquidで複数ipアドレス設定

プロクシサーバーを運用しており、squidを利用しているのですが
複数ip利用の必要性が出てきたのでその際のメモを残します。

squidの複数ip運用は英語でも情報がなく、ハマる方がいるかもしれないので念のため。

例)
ip1:200.200.200.200
ip2:200.200.200.201

以下を編集します。

vi /etc/squid/squid.conf

まず、ポートのリスンに追加

http_port 200.200.200.200:3128
http_port 200.200.200.201:3128

aclを記述します

acl ip1 myip 200.200.200.200/32
acl ip2 myip 200.200.200.201/32

outgoingアドレスを設定

tcp_outgoing_address 200.200.200.200 ip1
tcp_outgoing_address 200.200.200.201 ip2

そして、dns serverの設定も変更する必要があります

dns_nameservers xxx.xxx.xxx.xxx

/etc/init.d/squid restart

 

これで完了。知っていれば簡単ですね。