Showing posts with label ssh. Show all posts
Showing posts with label ssh. Show all posts

Monday, September 01, 2008

Remote login OS X

This enables logging into the Mac from a remote computer.
The steps are:
On the Mac (as server):
1. System Preferences >> Sharing : Here check the box Remote Login and select who you want to use this facility in the "Allow access for" box. Note the remote login command. In my case it's

ssh paul@192.168.1.5

In my case, this didn't work unless I used
sudo ssh paul@192.168.1.5

Without sudo I got a lot of stuff about unknown keys after which it went back to the command prompt.
With sudo, on the other hand, I was given the option to accept, or not, the authenticity of the host. After typing "yes", the connection was made.
Now I could delve into whatever directory on the Mac from Ubuntu on the Dell and use scp (without sudo) a file to the Desktop of the Dell with
scp file.ext 192.168.1.12:~/Desktop

This caused me to be asked again to accept or not the authenticity of the host (this time the Dell was the server or host).

Monday, August 04, 2008

Remote access beyond your router

This is a nice tutorial on how to use NXserver and sshd in Ubuntu to connect to a remote computer anywhere in the world.
Strangely though, I seem to be falling at the first hurdle here as in the section called "STEP 1: Testing SSH", I get this

$ ssh localhost
The authenticity of host 'localhost (127.0.0.1)' can't be established.
RSA key fingerprint is 5e:13:99:b5:12:51:9c:1e:99:8e:25:ec:ef:42:33:ad.
Are you sure you want to continue connecting (yes/no)? yes
Failed to add the host to the list of known hosts (/home/paul/.ssh/known_hosts).
paul@localhost's password:
Linux ubuntu-mac 2.6.26-5-generic #1 SMP Sun Aug 3 01:25:54 UTC 2008 i686

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

To access official Ubuntu documentation, please visit:
http://help.ubuntu.com/
Last login: Mon Aug 4 23:32:31 2008 from localhost


Then, as per the tutorial, I type
ssh paul@xxx.xxx.xxx.xxx (where the x's represent my external IP)

and get this after quite a delay
ssh: connect to host xxx.xxx.xxx.xxx port 22: Connection timed out


Actually, I really don't understand this last command and maybe I've misinterpreted it. Right now it looks like I'm trying to ssh from Ubuntu on my Mac back to Ubuntu on my Mac. Doesn't seem right.

Monday, July 21, 2008

Transfer files Linux to Windows

Now that I have Cygwin installed in Windows, it actually quite simple to transfer a file from Linux (only tried Ubuntu so far) to Windows XP (didn't yet try the other way around and, indeed, I'm not sure I'd know how to do it).
After that I just ran this in Ubuntu
scp "file.name" 192.168.1.139
and the file seemed to transfer (once I had input the password) without problem.
However, it ended up in c:\Cygwin\home\paul\ and then I could use Windows Explorer to open the file (a .pdf file).
I also tried going from KuruminNG to Mac OS X but this failed dismally up to now.
I tried to start sshd using this command:
/usr/libexec/sshd-keygen-wrapper -i
but, although this executed without error, I couldn't find any ssh stuff in ps -e so not sure if the command actually did anything at all.
Nevertheless, when I subsequently ran
ssh "file.name" 192.168.1.4
from KuruminNG, this completed cleanly without error. However, I was completely unable to find any unison.log file on the Mac.

Sunday, July 20, 2008

Transferring files between computers.

I have two (of my own) computers but there are actually a total of six on our router, so a system to transfer stuff between computers should be very useful.
One way, of course, is to email the file to yourself. This has the advantage that it can go anywhere in the world and will stay available to download anywhere, anytime for as long as you want.
However, there is a 20 MB limit on Gmail attachments which might be a problem if you want to send over a .tar.gz of a music album, for example.
I've experimented a lot with Giver here (see Labels) and it really works well, but apparently only in Gnome. Certainly I've had problem in KDE.
Another tool I use a lot is cl1p.net which is very useful and can transfer up to 30 MB.
Of course, SSH provides a lot of opportunities for this sort of transfer. This guide is very useful and outlines how to use the scp command.
Essentially, if you have a file Z on the Desktop of your local computer and want to transfer Z to a remote computer on your network with IP 192.168.1.xxx first make sure sshd is running on both computers and then just cd into ~/Desktop on your local machine and type this in a terminal:

scp Z 192.168.1.xxx:/home/user/Desktop

Z will now transfer over without any size restrictions.
As can be seen, scp is essentially the cp (copy) command for transfer between computers.
The guide in the last link also talks a lot about rsync. Here's another, but extremely old, tutorial on rsync. This rsync guide is much more modern.

Monday, July 14, 2008

Kurumin and ssh

Following on from what I mentioned yesterday regarding not being able to open any apps (cannot connect to X server -- error) when Kurumin-Dell as client connected to Ubuntu-mac or Foresight-mac as server.
I thought perhaps this was due to Kurumin using kde 3.5.9 and the server OSes using Gnome.
However, today I tried connecting to Sidux as server (with KDE 3.5.9 and got the very same error (cannot connect to X server).
Did a bit of googling and the trick is to use this command

ssh -X 192.168.x.y app_name

with the -X switch being the one that allows you to overcome the X server problem.
Allows you to connect to Gnome in the server too.

Openssh in KuruminNG

Openssh-server is available in the KuruminNG repos. So I installed it.
Then I ran it with this command

ssh 192.168.1.4
(where the IP was for Ubuntu on the Mac)
This worked fine after I accepted the IP.
However, even though I could see everything on the Mac (e.g using ls at the command prompt), I couldn't get even a single thing to work.
Most gave the error "Can't connect to X server".
This could well be that kurumin works in KDE 3.5.9 while Ubuntu was running with Gnome. So basically, I was trying to open kde stuff in gnome.
I'll have to research if this is totally out of the question.

Saturday, July 12, 2008

More ssh progress (including ssh'ing to WinXP)

I had been trying to ssh into Margaret's computer (running Ubuntu) but no matter what I did always got a permission denied error.
So, it appears you can ONLY ssh into another computer(server) if you have an account with the same name as you have on the client.
So, I created my own user account in Margaret's Ubuntu with the same username and then, no problem. Connection made.
So, I rebooted to Windows XP on Margaret's computer and used this guide to install Cygwin which allowed me to ssh from the client (Ubuntu-dell) to Windows XP.
However, couldn't think what to do once I got there as it's quite some time since I seriously used Windows.
Here's a link I'll probably use tomorow to ssh into Mac OSX.

What they don't want you to know about ssh

Jokey title just to get your attention -- sort of thing you'd see on Digg or, worse, Reddit.
But there is an interesting human trait hidden in this title. The assumption that the world is divided into two groups; us (of which group I'm, of course, a part and who are good, kind-hearted, fun-loving, normal people who base their visible lifestyle and public opinions on all the appropriate zeitgeists) and them (whose only purpose in life is to prevent in the most heinous manner "us" from having fun and continuing peaceably with our good lives. They are just plain "bad" people and there's an awful lot of them about). Note that "them" refer to the "they" who just don't want you to know so much stuff.
Of course, it must be clear to anybody whose brain is properly functioning, AND at the same time is at least as big as a peanut, that this is complete nonsense.
Nevertheless, because of its prevalence in modern thought, it seems to be something that was useful in our evolution from the brutes of 150,000 years ago into, well, the brutes we are today.
But while this belief may well have been useful to our hairy, uncultured raw-meat devouring ancestors, I have doubts about how beneficial it is in our slightly more enlightened times.

OK, enough philosophising, what did I intend to talk about?
Well, I had mentioned a day or two ago that I wasn't able to ssh from Foresight (Dell) to Foresight (Mac). Part of this was because I hadn't properly started sshd on the server (Foresight-mac) but I got over that as explained yesterday.
Then when I tried again I got this message:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

and a lot more stuff finally ending in
Host key verification failed.

The problem here is that the rsa key in ~/.ssh/known_hosts referred to the same IP but for Ubuntu.
But why could it just not write the Foresight server rsa key into the same file without overwriting what was already there?
Probably for security reasons. After all, if that were the case, then essentially any hacker could cause you to connect to a hacked computer. Nasty!
Nevertheless, it's perhaps surprising that you're not given the option to accept another rsa key.
In any event this is easy to do manually.
First, just delete your present ~/.ssh/known_hosts file (having first copied it somewhere. Then try the ssh -X command again. This time, it will write the key to your known_hosts file. Now, you just have to copy the old key from the copy of the file you deleted and paste this into your newly generated ~/.ssh/known_hosts file.
Now, you can ssh into either Ubuntu or Foresight at 192.168.1.4 (this is my situation).

Edit (12-07-08):
Actually, in the various attempts I made today to connect to various servers, mostly the client did write the "new" rsa key to ~/.ssh/known_hosts although two or three times it didn't. As of now, i really don't understand why sometimes it did and sometimes it didn't. Can't rule out that it was just a silly mistake of mine at this stage.

Friday, July 11, 2008

Starting sshd

In Ubuntu Hardy, sshd starts automatically on boot although I don't yet know how or why. Certainly there's nothing in sessions to start it.
However, in Foresight only ssh-agent starts at boot.
I had been using

/etc/init.d/sshd start

but this gives an error.
This post in the Foresight forums pointed me to
sudo service sshd start

and this works fine.

Still having some troubles with host recognition but lots of stuff to read on this.
Funny I didn't have any of these problems in Ubuntu or Foresight>>Ubuntu.

Wednesday, July 09, 2008

SSH -- let's take a look

I decided today to try out ssh.
I used this tutorial and it really is as easy as the guy says.
He does leave out one important point however. This is the fact that unless you get ssh-RSA key of the remote computer into your ~/.ssh/known_hosts file you'll have a little trouble.
Actually, the fact that it's not a lot of trouble in indicative of just how insecure ssh really is.
Here's what happened to me.
1. Did this on the Mac (Ubuntu)

sudo apt-get install openssh-server

2. Then opened up Foresight on the Dell and typed
ssh -X 192.168.1.4 tasque

3. Get a message telling me what the RSA key is and that it couldn't be added to the known_hosts file. But then it asks do I want to go ahead anyway (hmmm......)
4. So, I typed 'yes' (note it doesn't accept just a return key; you have to type 'yes')
5. Then it came up showing I was linked to the other computer (hostname became IP of other computer). After providing the login password for the remote box, I was away. No problems.

However, it's a lot more tidy looking to get the ssh-RSA key to be written to the known_hosts file. This is just a permissions problem.
So, I opened the file in root Nautilus (open as sudo nautilus) and changed the own of the file to my user and the group to me.
Then I started up ssh again and this time it went straight to the password request.
After this I changed the owner and group of the known_hosts file back to root.

Then I tried
ssh -X 192.168.1.4 /usr/bin/lastfm

and a Last.Fm dialog opened on the Dell. Once I typed in what I wanted to hear, music came out the Mac.
This is nice, particularly that you don't need to be in Ubuntu in both computers. I'll have to see between what OSes I can conveniently ssh.

Edit (10-07-08):
Later on I switched client computer to Ubuntu rather than Foresight and left the server (Mac) on Ubuntu.
Now when I tried to ssh into the Mac, I got an message saying "An application wants access to the private key 'id_rsa' but it locked.
As my usual password didn't work I was in trouble as that dialog just wouldn't go away unless I hit Dent which shut everything down.
Luckily I found this reference and the solution was to go into Gconf Editor and go to Apps>>Gnome-Keyring>>Daemon Components and uncheck the ssh box. Then reboot and no more Private Key dialog.
Interestingly, this time ~/.ssh/known_hosts was owned by me.