Showing posts with label PuTTY. Show all posts
Showing posts with label PuTTY. Show all posts

Monday, July 9, 2012

Managing Virtualbox Headless

I just copied a virtual machine from a Windows 7 host to an Ubuntu host. It was rather painless:
Stop the original guest vm, copy the folder, set up a new vm, use existing hard drive, and you're up (generally). I was using smoothwall, so I needed to mimic my network configuration, but otherwise, that's about it.

The fun part was the creation of the destination vm on a headless host. Sure, I could learn some command line, but I wanted a GUI. I added Cygwin-X to my Windows 7 box,
startx (opens X)
xhost+ (allows connections to X)

Opened putty with X11 forwarding to my linux box, then in putty
VirtualBox

tweak tweak tweak

back in putty
vboxheadless -s vmName &

close everything, go on with life.


Sunday, November 7, 2010

How to run an application on resume from standby

or sleep mode...

Should work for Vista or Windows 7:
click the Start menu
type in Task Scheduler and run it
On the right, Create Task
Give it a name
(Run only when user is logged in is good and important)
click Triggers
Begin the task On an event
Log: System
Source: Power-Troubleshooter
Event ID: 1

if it's network related, you may want to
[x] Delay Task for 30 seconds

click Actions
add the parameters that will run your application on resume

click Conditions
If you're on a laptop/notebook, you may wish to uncheck
[x] Start the task only if the computer is on AC power

If it's network related, you'll want to check
[x] Start only if the following network connection is available

click Settings
if it's network related, you may want to check the "if task fails", restart every 1 minute up to 3 times.

click ok.
Test it

What would you want to use this for?

I'd use it to reconnect my ssh link if my laptop went to sleep, especially if I'm using it for tunneling.

Friday, May 7, 2010

Vista, Windows 7 doesn't have telnet - so get PuTTY

Get PuTTY
Here's how to use plink to test a port, like port 25:
plink -telnet your.domain.com -P 25
(Ctrl-C to quit)
or for interaction, PuTTY, in telnet mode.

Tuesday, March 9, 2010

Tunneling with plink (PuTTY)

This establishes a putty/ssh/plink connection from windows so a nonsecure application can be tunneled through it and then can be closed cleanly.

What is plink?
It's a command line version of PuTTY

What does tunneling mean?
In the case being presented here, any activity that will go to a port on the localhost will do what it should do on the remote site, but do it securely.

No, really, what does that mean?
Let's say you hear that telnet or mysql or ftp isn't that secure, because passwords are flying over the Internet in clear text. That is bad because that password or data isn't encrypted. Yes, I know about sftp, psftp, advanced mysql configuration, ssh, etc. Calm down a bit. If an application doesn't support secure communication, this is what ssh tunneling is about -- providing the secure "tunnel" to do those things.

How do I do it?
1) Make the link
open a command prompt
plink -ssh -L 21:localhost:21 remoteusername@remotedomain

2) use the link
open another command prompt
ftp localhost
and do what you want.

This only works if the remote site is running an ftp server on localhost. (huh?) It means, it only works if the site you want to connect to is listening for ftp connections on 127.0.0.1 (localhost). If it's listening for ftp connections on a local IP address, change localhost in the Plink connection to the local IP address of the REMOTE server. You will still on the local side connect to localhost.

plink -ssh -L 3306:localhost:3306 remoteusername@remotedomain (for use with mysql running on the remote domain. Again, if mysql is listening on a specific IP address, change localhost to the IP address that is configured for mysql.)

Don't forget... this is intended for the *client* applications connecting to the port on the local machine. It will be transparent to the application, but connect to the remote server. Oh, btw, this now establishes the connection securely.

Why would you do this in plink? Frankly, I don't know, except plink was designed for scripting. Most of the examples you'll find on the Internet say, "Usually Plink is not invoked directly by a user, but run automatically by another process. Therefore you typically do not want Plink to prompt you for a user name or a password." Plink is designed to run interactively with things like scp. You should check the furnished manual about that, especially how to put plink in the path, and I strongly suggest you create, save and use all the options (putty session) to minimize the interactivity.

Here's a fun script, though: WARNING! This creates and deletes a file called goawaynow on the remote server!

FIRST sample batch (scheduled?) to connect:
plink puttysessionname rm goawaynow
plink puttysessionname until (test -e goawaynow); do true; done; exit


SECOND run a command like this in another batch (scheduled) after you do the first:
mysqldump -h localhost dbname > dump.sql
plink puttysessionname touch goawaynow



(What does it do?)
First, understand that there is a lot of different customization that can be made to establish the plink connection. Don't be afraid to make changes. But you should necessarily run the two batches separately. The first connect batch removes the goawaynow file. The next line establishes the port forwarding and keeps the link open. The configuration is within the putty session, but you still need to append the until stuff. It basically says, "until goawaynow exists, do nothing, and after goawaynow exists, exit."

The second batch does whatever it needs with the connection, then the next line is supposed to create the goawaynow file, which closes the connection (because the infinite loop above is testing for it).

I'd also like to point to http://thinkhole.org/wp/2006/05/10/howto-secure-firefox-and-im-with-putty/ which has really good comments to make what I said above better. (-qTfNnL?)

Wednesday, October 29, 2008

PuTTY, SSH, Web Browser tunnel

This bypasses your proxy server, tunnels through your own SSH server, and provides web access.
  1. Have a running ssh server, accessible from the Internet. http://www.dyndns.com can help give you a name to your IP address, if you have a dynamic one. Making the dyndns connection is beyond the scope of this tutorial.
  2. Create a PuTTY session to your ssh server. Chances are, if you know what step 1 is about, you've already created a PuTTY session to it.
  3. Inside PuTTY's session, go to Connection, SSH, Tunnels
  4. Type a number (8080?) into Source Port. Click Dynamic, Auto, and then [Add]
  5. Save the PuTTY sesssion
  6. Connect to your PuTTY session
  7. Configure your browser's proxy settings: Manual, SOCKS v5, 127.0.0.1, port (whatever number you used as your Source Port in 4.)
  8. If you go to http://www.gwy.org/yourip.php, you should now see that your IP address is your ssh server.
There are interesting side effects that happen when you do this, especially since you usually can ssh connect any time you have any internet access.

Friday, March 28, 2008

Cygwin, X, and PuTTY

For Christmas last year, I got a new computer, upon which I immediately installed Ubuntu. Yay, Ubuntu! OK. And customized it to my liking. Also, if you care, I had eschewed the default email system for claws-mail, which I had also installed previously on my Windows Laptop. While not completely as GUI-rific as Thunderbird, I like the "individual message is a file" methodology rather than Thunderbird's "large file contains all messages" which basically failed miserably for me.

Right, so that's the background. The point of all this is that I'm here, late at night, and for whatever reasons known only to me, I wanted to check my mail on my now rarely used laptop (it has a broken hinge) while watching TV. Well, I didn't really want to check mail with the client on my laptop, because I didn't need or want to store the mail on the laptop. Plus, I didn't remember if I left mail on the server, so .. hey, stop asking questions, ok? :)

So, I remembered that I had already installed cygwin and X windows. I clicked on my cygwin icon, typed "startx" and then in the xterm box, "xhost +". Then I opened PuTTY that had a session that Forwarded X connections, connected to my Ubuntu box, logged in, then typed in "claws-mail" and I have the application running on my desktop in Windows. I suppose I could have VNC'd or other type of remote connection. However, the X interface makes the result almost seamless with Windows proper.File system is still on my Ubuntu, and so anything that happens disk-wise doesn't affect my laptop.

Blog Archive