Beyond the Sky

The place where surface stop and share the experience of life

Subscribe to RSS feed

Posts tagged with "ssh"

Install OpenBox for cygwin

, , , ...

First of all, I was quite amazed when I saw KDE, GNOME can be install at cygwin. devil I am going to turn my office Windows box into LINUX ( somehow ... ) Okay, actually I search for fluxbox, but I can only find openbox and it is old version.

Anyway, I just wanna try how powerful of cygwin on X11. So I run setup.exe at c:\cygwin and check openbox, which it automatically solves all dependencies for me. To run openbox, I need to create a file and run initx.

echo "exec openbox" > ~/.xinitrc
initx


TaDa bigsmile

Okay, at that moment I found a very interesting page http://www.cs.wcupa.edu/~rkline/cygwin-install.html
Which shows you the way to actually open linux X-packages which store at other linux box.
Simple steps:
1. Type xinit [ This will initiate X server and openbox is start ]
2. Right click the open xterm.
3. Type ssh -Y username@ip-addr
4. Once you login with password, then run any packages you have, for let say gaim &

It is a bit slow, but gaim is loaded and run like you have install that in the local machine.

Access to PC in LAN after login to ssh server under cygwin

, , , ...

I spend the entire day figure out how to do that, after successfully installed sshd and cygwin on windows XP. To read about how to setup SSH server on windows box, please refers back http://my.opera.com/mysurface/blog/show.dml/372169

To login to others PC by specifing IP, username and password. You need to use msdos command which is NET USE. First of all my command is correct, but it couldn't works. Bellow shows the usage and example I can obtain at internet and also cygwin mailing list.

NET USE
[devicename | *] [\\computername\sharename[\volume] [password | *]]
        [/USER:[domainname\]username]
        [/USER:[dotted domain name\]username]
        [/USER:[username@dotted domain name]
        [/SMARTCARD]
        [/SAVECRED]
        [[/DELETE] | [/PERSISTENT:{YES | NO}]]

NET USE {devicename | *} [password | *] /HOME

NET USE [/PERSISTENT:{YES | NO}]


Examples:
 NET USE \\192.168.1.10\documents /USER:neo neospasswd 

With putting like this, it would not work and given error message like :
 System error 67 has occurred.
The network name cannot be found. 

Searching through the mailing list and some forum, it gives me all silly solutions which it doesn't work at all, such as mount manually, etc. And some of them stated in the mailing list that they giving up and just treat it doesn't work at all. Finally I found the solution, i have to put single quote within the IP address like this
 NET USE '\\192.168.1.10\documents' /USER:neo neospasswd 


I have to put password as the last argument, which I do not feel so confortable. By right, without specifying any password, it will prompt you from type in the password, some how it doesn't work that way. So It is time to apply bash shell script which i had learn for so far. To make it flexible, I had write a simple one.

#!/bin/sh

#Get the info I want, password will not display
read -r -p "IP or Server Name to login (ig \\\\ip-addr\\target-dir): " name
echo $name
read -p "Drive to MAP : ( A - Z): " drive
read -p "Login: " login
read -s -p "Password: " passwd

#UnMap the drive, i have no idea how to check this.
#Therefore, I just run this everytime
net use /delete $drive":"

#construct the command and run it.
str="net use $drive: '$name' /user:$login $passwd"
eval $str

if [ $? == 0 ]
then
        echo "The drive will be in /cygdrive "
        echo
        exit 0
fi


Install SSH server to your Windows Box.

, ,

If you have windows installed and switch on 24 seven, and you feel that you want to copy files or manipulate files remotely and even access to the LAN networks. If you want to have remote desktop to windows box, then you may consider VNC. If you familier with ssh and scp and are not interested in using GUI, then you would like to read this futher.

You have no problem to connect to any linux server, ssh client putty is a very lightweight tools for you. But if you want to setup ssh server at windows, a very first thing you need is CYGWIN. Cygwin is a software that support various POSIX based packages and tools that originally running on (Linux, BSDs) to run at windows. The first time I heard about cygwin is last 2 years when I want to setup Network Simulator 2.26. At that time, cygwin is very difficult to setup but today, cygwin becomes very easy.


Steps to setup Cygwin and ssh:

1. Login as administrator or user with admin privilege.
2. Make sure all users have set password, check control panel -> user account. Set password for all users, logout and login again.
3. create a folder to store all packages c:\cygwin
4. Download setup.exe, click http://www.cygwin.com/setup.exe and save it to c:\cygwin
5. Run it and click next next next, pick a mirror and continue until you see selections menu.
6. Click view button until is shows Full view.
7. Search for OpenSSH and vim, or other packages you like to include with. Basically OpenSSH would be enough, you can install other packages later by running setup.exe again.
[Installation will take sometimes to download ... ]
8. Right click My Computer -> Properties -> Advanced -> Environment Variables
9. At System variable , click NEW button, enter variable name "CYGWIN" and value "ntsec".
10. Select the Path variable and click the EDIT button.
11. Append ;c:\cygwin\bin to the end of the existing variable string.
12. Okay, now can start cygwin, double click the icon.
13. Type ssh-host-config
14. Say "yes" to privilege separation, create local user sshd and install sshd as a service.
15. When the script stops and asks you for "CYGWIN=" type ntsec
16. Type net start sshd
17. Okay if you want to create more user accounts, please do so and then open cygwin again and
18. Type mkpasswd --local > /etc/passwd
19. Type mkgroup --local > /etc/group
20. Okay you are done, take any ssh client and try it out. you c: is at /cygdrive/c



Do not forgot that SSH uses port 22, so you need to add exception port 22 at windows firewall.

Click Start...Control Panel....Security Centre....Manage Security Settings for Windows Firewall....Exceptions tab....Add Port...
"Name of port" is ssh "Port number" is 22 (check the "TCP" checkbox)



For details please check out this page http://www.chinese-watercolor.com/LRP/printsrv/cygwin-sshd.html

Next comming up, I am going to write on how to access LAN networks with using net use and also performs remote desktop to linux box with openbox under cygwin.

Fail to access using ssh

, ,

I facing the problem of accessing a server using ssh, which the ssh conplain that I might be ear drops. The reason is i change the server ip to another server. Let say server A uses 202.188.0.1, because server A is down, so i setup another server B uses 202.188.0.1. From the remote site, when i ssh to 202.188.0.1 it do discover that the server have been changed, so it do not allow me to continue ssh.

The fastest hack, i remove ~/.ssh/known_host, then it allow me to ssh again. But some how this is not the right way. I do vi known_host, it do contains multiple entry because i do ssh to many server, i do not have any ideas which to remove. Wandering is there any way to resolve that, because if I delete known_host, all authetications for all server will gone.