Showing posts with label unix. Show all posts
Showing posts with label unix. Show all posts

Thursday, November 05, 2009

Connecting to ssh servers running on non-standard ports

If you are running your ssh server on a port different than 21, for example 22, you can connect to the machine like this:

ssh mymachineip:22

or 

ssh mymachineip -p 22

However, there is an easier way:

Create the file  ~/.ssh/config, then fill it like this:

Host mymachineip

Port 22

Now you can just ssh to the machine: ssh mymachine

Monday, November 02, 2009

Reconnecting to a screen session

When there is only one screen session, screen -raAD attaches to the running screen. So far so good.  

However, if for some reason, there are more than one screen sessions, (screen -ls should give you those), screen suggests that you need to do screen -r  [[pid.]tty[.host]] to reattach. 

However, this simply doesn't work at first and yields weird errors like:

There is a screen on: 5541.pts-1.shannon (11/02/2009 04:40:02 PM) (Attached) There is no screen to be resumed matching 5541.pts-1.shannon.

This is utterly confusing, since it first says that there is a screen, but there is no screen to be resumed. What this means actually is just that however: one first has to detach that screen in order to attach to it. So, yes, there is a screen and that screen is not a screen one can connect directly.

The solution is to give the -d parameter to detach it at first, so

screen -d -r  5541.pts-1.shannon

should work. In fact, I guess screen -r -d 554 works too. That 554 portion has to be unique though, so screen -r -d 5 works too if no other screen session starts with a 5.

Saturday, August 22, 2009

Weather Information on Command Line

Weather information can be obtained at command line using a Python script that retrieves the weather information from Yahoo API found here at GitHub.

For Ankara, the location code is TUXX0003 and I aliased it in ~/.bash_profile as:

alias hava='weather.py TUXX0003 -m c -f 2'