Cocoa libssh2 wrapper
I’ve modified a simple wrapper for the libssh2 library that now has the following functionality:
- Code moved to separate classes to allow reusability
- Multiple sessions to different servers can be achieved with a few lines of code
- A Session can be passed to the operator class allowing operations (commands sent to it), more will be added
SSH with Cocoa (Xcode and libssh2)
I fought with this about a year ago, and for some strange reason never managed to get things to compile or link. I chalk this down now to my lack of understanding with Objective-C/linking concepts. However it turns out that it is relatively simple (ensure you have Xcode 4 installed before trying).
- Point browser to http://www.libssh2.org/ and download the latest snapshot to a temporary location.
- Open a terminal window and navigate to the directory containing the the source files and run the following:
dan$ ./configure
- This will output numerous content to the terminal window, present a summary of the configuration options and create a header file needed for compilation. (Running make / make install is NOT required).
- Open Xcode and create a new Xcode project, which should be a (Mac OS X -> Framework & Library -> C/C++ Library) and give it a Product Name (e.g. libssh2) and ensure that the type is Static then click create.
- Xcode will open with an empty project displaying the Build Settings. At this point we can start adding the files that are part of the libssh2 source tree.
esxtop showing raw output
Using esxtop? Being presented with this:
Expecting this:
Then change your TERM type
# TERM=’xterm’
# esxtop
Read MoreGetting files through a terminal window
This is a technique I had to use numerous times for a previous job where I would need to transfer files from servers that could not be connected to directly. In the majority of companies there will be numerous networks, where “jump boxes” are required to get across various networks and get to the server in question.
The usual approach of moving files to servers would be through a variety of means (FTP/SCP/NFS/CIFS etc.), however in the case of numerous jump boxes and networks would mean that having to transfer the file between each jump/network. It is possible to use copy and paste however this would only work in the case of text files, trying to display or copy binary data can cause all manner of issue and really mess up your terminal window. So for me the best solution is to UUEncode the binary data into ansi text which can be safely copied out of the terminal window, pasted into a file on your local machine and UUDecoded back to binary data again.
To do this simply UUEncode a file, and the output will be presented to STDOUT i.e. the terminal window.
$ uuencode test.rpm test.rpm
Note: the double typing of the name is required as the first argument is the file to uuencode, whilst the second argument is the name of the file that will be outputted. The output will be presented to STDOUT as shown in an example :
begin 644 test.rpm
M"GP]+2TM+2TM+2T]6R!796(@=G5L;F5R86)I;&ET:65S('1O(&=A:6X@86-C
M97-S('1O('1H92!S>7-T96T@73TM+2TM+2TM+2T]?`I\/2TM+2TM+2TM+2TM
The next step is simply to copy everything from the word “begin” to the word “end” out from the terminal window and then paste it into a text editor of your choice on your local machine under a temporary name. This will then need opening with uudecode, which will then process the text and spit out the file under the filename specified with the encoder.
$ uudecode temporary.uua
In the same location will be the decoded file.
Read More




