PDA

View Full Version : Using SSH


Kraetos
2008-01-23, 15:24
I need to learn how to use and configure SSH. There are times when I am in the comp. sci. lab and it would be great if I could SSH back to my MBP in my dorm.

Where's a good tutorial on this kind of stuff? Thanks! :)

Brad
2008-01-23, 15:32
What's there to need to know about configuring SSH? Turn it on (one button in System Preferences: Sharing) and connect! :)

Or are you looking for a general primer on using command line shells (bash, tcsh, sh, zsh, etc.)?

Yonzie
2008-01-23, 15:34
open terminal, type "man ssh" and/or "man ssh_config".

Other than that, my best suggestion is a blood transfusion from a UNIX hacker.

tomoe
2008-01-23, 15:50
What's there to need to know about configuring SSH? Turn it on (one button in System Preferences: Sharing) and connect!
This is great as I've been trying to get this working for a while. However, I've turned on SSH on my home laptop, then if I try to connect to it from school using ssh <shortusername>@<my IP from whatismyip.org>, terminal basically hangs and eventually I get a either a) "Timed out" error, or b) "Connection refused" error. Anyone have this experience?

chucker
2008-01-23, 15:58
This is great as I've been trying to get this working for a while. However, I've turned on SSH on my home laptop, then if I try to connect to it from school using ssh <shortusername>@<my IP from whatismyip.org>, terminal basically hangs and eventually I get a either a) "Timed out" error, or b) "Connection refused" error. Anyone have this experience?

Are you sure your school doesn't firewall that sort of traffic?

Yonzie
2008-01-23, 16:17
Try it from a friends place before screwing around with anything and always make a backup of the configuration if you're making changes.
To check if ssh itself works, you can just open terminal and ssh to your local IP.

Banana
2008-01-23, 16:25
Other than that, my best suggestion is a blood transfusion from a UNIX hacker.

Extra points if this hacker wears suspenders and has quite large beard!

tomoe
2008-01-23, 16:29
Are you sure your school doesn't firewall that sort of traffic?
I'm pretty sure they don't firewall SSH...we're sort of encouraged to use it for transferring large data files. I mean, if I'm at home on my laptop, I can easily SSH into my network drive at school, and then once I'm at this point (the network drive), I can alos SSH onto the local drive of the iMac I use, and have full use of applications that support 'tunneled' graphics (pardon if this is the wrong word) in X11. I tried trashing my ~/.ssh files on my laptop, and on my networked drive, to see if this could relieve the problem, but alas, it didn't work.:confused:

EDIT: I also forgot to mention I have no problem SSHing around on my LAN at home, use it all the time to transfer files, etc between the desktop and laptop.

colivigan
2008-01-23, 16:42
Can you describe your home network setup? If you're behind some kind of broadband router, you'll probably need to set up port forwarding (http://en.wikipedia.org/wiki/Port_forwarding) on the router to pass SSH connections to your MBP.

Koodari
2008-01-23, 16:45
Hmm.

tomoe, do I understand correctly that you can sit down at the school computer (or SSH into a school machine) and subsequently from there SSH into the iMac which is at your home? But you can't SSH from school into the laptop even if you activate SSH serving on it, disable the firewall, and plug the laptop in the same exact place the iMac is normally plugged into? How do the laptop and the iMac connect to the Internet, for that matter?

I'm pretty sure you'll find a firewall or port forwarding at work somewhere (the laptop, a router of yours you didn't mention, a router at the dorm...) that explains this. They can mess connections in just one direction.

Yonzie
2008-01-23, 17:20
Koodari: I understood it as the iMac at school.

I'm with UncleJohn about there probably being a router or something that blocks outside access to your LAN.

tomoe
2008-01-23, 17:25
Hmm.

tomoe, do I understand correctly that you can sit down at the school computer (or SSH into a school machine) and subsequently from there SSH into the iMac which is at your home? But you can't SSH from school into the laptop even if you activate SSH serving on it, disable the firewall, and plug the laptop in the same exact place the iMac is normally plugged into? How do the laptop and the iMac connect to the Internet, for that matter? Sorry for the lack of clarity. There's an iMac I use at school (in an office) that I SSH onto sometimes to run programs/store large data files.

I'm pretty sure you'll find a firewall or port forwarding at work somewhere (the laptop, a router of yours you didn't mention, a router at the dorm...) that explains this. They can mess connections in just one direction.
I have Port Forwarding setup on my broadband router (Linksys WRT54G running DD-WRT); I'm using the following setup:

Under...
Applications:Port Forwarding:

Port From is set to 22
Port To is set to 22
IP Address: set to IP of Client (i.e. computer at school)

I'm not at home right now, but I'll double check and run SSH using the -v flag to see if that spits out anything.

Yonzie
2008-01-23, 17:44
IP Address: set to IP of Client (i.e. computer at school) There's your error. It should be the IP of the computer you want to connect to from the outside, ie. the local IP of the MBP. You'll probably need to give it a static IP to avoid problems.

EDIT: Basically, you tell the iMac to SSH to your public IP. Your public IP is the router. The router doesn't know what to do with the connection, so it drops it. This is where you tell the router that if it gets an connection on port 22, it should forward it to [some IP on the local network behind the router].
The same is not true for the iMac, since it has a public IP address (meaning one that is "visible" to the entire internet (your local network cannot be routed on the internet, the router acts as an interpreter)).

Koodari
2008-01-23, 17:45
The key to all of these problems is elimination. First thing I'd do is bypass the router and plug the laptop straight into the wall. If you get SSH going that way, then you have the problem narrowed down to the router. If it doesn't work, I'd keep the router on the sidelines until you figure it out or give up, just in case the router *also* has a problem - the last thing you want to do is to try some fix, and think it didn't work, when it actually did and another problem just isn't letting you see it.

Kraetos
2008-01-23, 18:02
What's there to need to know about configuring SSH? Turn it on (one button in System Preferences: Sharing) and connect! :)

Or are you looking for a general primer on using command line shells (bash, tcsh, sh, zsh, etc.)?

Well then, there it is. I feel dumb. :o

I am familiar with bash so no problem there.

Now, system preferences gives me a local (10.0.1.x) ip addy for the SSH login. I am assuming that I would want to use my external ip if I we're to login from somewhere else?

Brad
2008-01-23, 18:55
Now, system preferences gives me a local (10.0.1.x) ip addy for the SSH login. I am assuming that I would want to use my external ip if I we're to login from somewhere else?
Correct!

And if you're behind a router, you'll have to configure port forwarding on the router as the folks above mentioned.

colivigan
2008-01-23, 20:20
And you'll probably need to configure your MBP with a static IP on the home network, since port forwarding needs a local IP address.

tomoe
2008-01-23, 23:06
There's your error. It should be the IP of the computer you want to connect to from the outside, ie. the local IP of the MBP. You'll probably need to give it a static IP to avoid problems.

D'oh! Worked like a charm once I entered the local IP. Thanks for the help. :D :)

Kraetos
2008-01-24, 00:41
Correct!

And if you're behind a router, you'll have to configure port forwarding on the router as the folks above mentioned.

Awesome. Got everything set up. Now I can access all my files from anywhere on campus - thats great. Thanks :)