Saturday, January 11, 2014

Find the public IP address of the system using command line

Commands to find Static IP address of the server

If you want to find the public IP address of the system. Run following commands.
# wget -q -O - checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'
If this is not working for you, try this.
# curl -s checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'
It does not show you the LAN IP address, it shows the IP address that you can access out side the LAN, if it is static.
# curl ifconfig.me
One of these four should work for you.
# lynx -dump ifconfig.me | grep 'IP Address'

No write since last change (use ! to override)

No write since last change (use ! to override)

If you are getting this error after using :q while saving your changes in command line editor.
Run following commands
:w
then
:q
Now it will ask to save the changes.

Tuesday, January 7, 2014

X11 forwarding request failed on channel 0

X11 forwarding request failed on channel 0
Error: no display specified

If you are facing this error while connecting remote server through ssh -X, see the post below.

When you try to open display of remote server on your system, you may get this error.

To remove this error, follow the solution.

Solution :

1) Open file /etc/ssh/sshd_config on remote server where you want to connect.

2) The following attribute must be uncommented in the file as well as set as yes.
X11Forwarding yes
Now restart ssh/sshd and try to connect to the server.

3) If X11Forwarding has been set as yes in the file and it is still showing same error, Find the following attribute in the file, uncomment it and set it no.
X11UseLocalhost no
4) Now restart ssh/sshd and try to connect to the server.
service ssh restart
or
service sshd restart
According to your Linux Distribution.

If you are still facing the problem after restarting ssh service, check there is a file .Xauthority in home directory of server.
If it is not there create it using following command.
First log in to the server command prompt using ssh and run following command there.
mkxauth -c
Now restart ssh/sshd and try again.