This guide covers the use of the WinRAR command-line tools to compress and uncompress files in a directory, and their use in batch files. This guide is an extension of a previous post, Automate Zipping Tasks using the Command-line Interface, that covered the use of command-line tools for two free compression utilities, IZArc and 7-Zip. The information in this guide was tested on a Windows PC running Vista.

compress

WinRAR is a popular and powerful archive manager that includes the command-line tools rar.exe and unrar.exe. Rar.exe is used to compress and unrar.exe to uncompress. Both executables are located in Program Files\WinRAR in the installable version. Although WinRAR is shareware, it can be used on a trial basis for 40 days. Using WinRAR’s command-line tools is similar those for IZArc and 7-Zip. The syntax for the executables is:

WinRAR <command> -<switch1> -<switchN> <archive> <files...> <@listfiles...> <path_to_extract\>

Examples to compress a folder:

rar a -r yourfiles.rar *.txt c:\yourfolder

creates archive yourfiles.rar and compresses all .txt files in c:\yourfolder and subfolders

rar a yourfiles 

creates archive yourfiles.rar and compresses all files in the current folder, but doesn’t include subfolders (note lack of extension, WinRAR will use the default extension .rar)

“a” command adds to archive

“-r”  switch recurses subfolders

Examples to uncompress a folder: 

unrar x c:\yourfile.rar *.gif c:\extractfolder\

extracts all *.gif files from yourfile.rar to c:\extractfolder\ (trailing backslash required) and restores the folder structure

unrar e c:\yourfile.rar 

extracts all files in c:\yourfile.rar to the current folder (folder structure ignored)

“x” command extracts with full paths

“e” command extracts and ignores paths

Basic rules for WinRAR:

  • When files or listfiles are not specified, all files in the current folder are processed
  • When specifying all files in a folder, yourfolder or yourfolder\*.* are equivalent
  • Folder structures are automatically saved in archives
  • WinRAR  uses the default .rar extension, but that can be overridden by specifying the zip extension in the archive name
  • Switches and commands are not case sensitive and can be written in either upper or lower case

Another point is that WinRAR doesn’t appear to use the Windows path environment variable, so it must be specified either at a command prompt, set permanently in the environment variable settings, or specified in a batch file.

To set it temporarily at a command prompt or in a batch file, just enter

set path="C:\Program Files\WinRAR\";%path%

To set it permanently in the Windows path, use start–>Control Panel–>System–>Advanced system settings–>Advanced Tab–>Environment Variables–>System Variables–>Path–>Edit. Add the path ;C:\Program Files\WinRAR; to the end (don’t forget the single semicolons at the beginning and end). Hit OK three times.

Using WinRAR in Batch Files:

Two batch file examples are provided. The first compresses all files in a folder, with the option to compress all files into a single archive or to compress them individually. The second batch file decompresses all .rar files from a folder and places the extracted files into another directory. Be sure to change the extension(s) to .bat before using either file.

compress_rar.bat

uncompress_rar.bat

 

Share

Two ways to use SSH to secure Internet connections are local port forwarding and dynamic port forwarding. Local port forwarding forwards web traffic from a server, while dynamic port forwarding transforms your SSH client into a SOCKS proxy server. Both can be useful for secure Internet access in insecure environments such as public networks. To use either, you need to be able to login onto a remote system. Both are easy to use.

Local Port Forwarding

Local port forwarding can be used to access specific sites from another machine. For example, to route traffic from www.somewebsite.com on a remote PC (user@yourdomain.com) to port 12345 on a client PC, the following could be entered into a command window:

ssh -L 12345:www.somewebsite1.com:80 user@yourdomain.com<host>

multiple connections may also be combined into one command as follows:

ssh -L 12345:www.somewebsite1.com:80 -L 23456:www.somewebsite2.com:80 user@yourdomain.com<host>

Use:
You just need to open a browser and point it to http://localhost:12345/ to securely access somewebsite1.com or http://localhost:23456/ to access somewebsite2.com.

Note: An IP address can also be used in place of yourdomain.com (e.g. user@192.168.1.1).

Dynamic Port Forwarding

Dynamic port forwarding is even more powerful as it allows you to securely connect to any web page and to bypass firewalls. To set it up, the following could be entered into a command window:

ssh -C -D 23456 user@yourdomain.com
  • The -C is optional and is used to enable compression, which can speed up connections
  • The -D enables dynamic port forwarding
  • 23456 is the port on the client PC

Use:
To use this connection, you will need to configure your browser to use a SOCKS proxy. See the following two articles on how to do this for your browser:

Make Tech Easier – How to Secure Your Internet Connection via SSH

Ubuntu Help - SSHOpenSSHPortForwarding (see Dynamic Port Forwarding section)


Useful Related Articles:

Debian/Ubuntu Tips & Tricks - SSH and Port Forwarding or How to get through a firewall

Linux Magazine – Port Forwarding with SSH

OpenBSD Man Pages for SSH - Manual Pages

Red Hat Magazine – SSH Port Forwarding

University of Victoria – An Introduction to the Black Art of Port Forwarding with SSH

Share
22. October 2011 · 1 comment · Categories: Windows · Tags:

Hard links, Junction Points and Symbolic links are linking mechanisms used to refer to other files, directories, or volumes. Generally, a Hard link is a file that acts like a representation of another file on the same drive without actually duplicating that file. A Junction Point (or directory hard link) is a type of hard link that acts like a representation of a directory, a partition or another volume. A Symbolic link (or soft link) is a file similar to a shortcut in that it points to a filename or directory name, but it’s handled at the system level rather than at the application level. Often confused with shortcuts as well as with each other, Hard links, Symbolic links and Junction Points are not the same; although like shortcuts, deleting either links or junction points usually won’t delete the target and vice versa (see exceptions below). Of the three, Symbolic links are more similar to shortcuts than either Hard links or Junction Points and are generally more flexible, easier to use and safer. When given a choice, most professionals recommend using Symbolic links.

Although Symbolic linking has been around since 1978 and since standardized in UNIX and UNIX-like Operating Systems, it’s been present in Windows only since Vista. Symbolic Linking was introduced in Vista to replace Hard Links and Junction Points and to enhance compatibility with UNIX and UNIX-like systems. Hard Linking for files and support for directory Hard Links (Junction Points) have been present in Windows since Win2K – often using different implementations in each succeeding Windows version. Because the development of linking in Windows has been relatively recent and ongoing, a number of different linking methods have been included, supported, or made available as third-party add-ons depending on the Windows version. Currently, Hard Links, Junction Points and Symbolic Links in Windows are only supported for the NTFS file system. Note that Windows does not support Hard Links or Junction Points to directories on remote shares; however, Symbolic Links can point to remote files and directories on SMB network paths.

Hard links, Junction Points, Symbolic links, and Shortcuts are further contrasted below:

Hard link (Linking for individual files):

  • A file that acts like a representation of a target file
  • Has the same size as the target without duplicating it (doesn’t use any space)
  • Interpreted at the operating system level (SW apps can act upon the target through the link)
  • Deleting the hard link does not remove the target file
  • If the target is deleted, its content is still available through the hard link
  • Changing the hard link contents changes the target’s contents*
  • Must reside on the same partition as the target file
  • Compatible with Win2k and above in Windows

* Some text editors save changed text to a new file and delete the original file, which can break the link. This behavior can be changed in some editors by forcing a save over the original file instead. See discussion at Jameser’s Tech Tips here for more information.

Junction Point (Directory Hard Link):

  • A file that acts like a representation of a target directory, partition or volume on the same system
  • Has the same size as the target without duplicating it (doesn’t use any space)
  • Interpreted at the operating system level – transparent to SW programs and users
  • Deleting the junction point does not remove the target*
  • If the target is deleted, its content is still available through the junction point
  • Changing the junction point contents changes the target’s contents
  • Can reside on partitions or volumes separate from the target on the same system
  • Compatible with Win2k and above in Windows

*A junction point should never be removed in Win2k, Win2003 and WinXP with Explorer, the del or del /s commands, or with any utility that recursively walks directories since these will delete the target directory and all its subdirectories. Instead, use the rmdir command, the linkd utility, or fsutil (if using WinXP or above) or a third party tool to remove the junction point without affecting the target. In Vista/Win7, it’s safe to delete junction points with Explorer or with the rdir and del commands.

Symbolic link (Soft Link):

  • A file containing text interpreted by the operating system as a path to a file or directory
  • Has a file size of zero
  • Interpreted at the operating system level – transparent to SW programs and users
  • Deleting the Symbolic link does not remove the target
  • If the target is moved, renamed or deleted, the link points to a non-existing file or directory
  • Points to, rather than represents, the target using relative paths
  • Can reside on partitions or volumes separate from the target or on remote SMB network paths
  • Compatible with UNIX and UNIX-like systems and with Vista and above in Windows

Shortcut:

  • A file interpreted by the Windows shell or other apps that understand them as paths to a file or directory
  • File size corresponds to the binary information it contains
  • Treated as ordinary files by the operating system and by SW programs that don’t understand them
  • Deleting the shortcut does not remove the target
  • Maintains references to target even if the target is moved or renamed, but is useless if the target is deleted
  • Points to, rather than represents, the target
  • Can reside on partitions or volumes separate from the target on the same System
  • Compatible with all Windows versions

Windows Applications for Creating Links:

A number of applications are available for creating links in Windows including those bundled with the operating system and third-party tools. Some of the more well known are summarized below.

Utilities included with Windows:

  • fsutil – a command line tool included with WinXP and above. It can only create hard links for files – it doesn’t create directory hard links (junction points) or symbolic links. Further information about this tool is available at Commandwindows.com.

usage: FSUTIL hardlink create new_filename existing_filename

  • mklink – a command line tool included with Vista and Server 2008 and above. The most current link creation tool included with Windows. It creates Hard Links, Symbolic Links and Junction Points.

usage: mklink [[/d] | [/h] | [/j]] <NameofLink> <Target>

/d – Creates a Symbolic link for a directory. If no flag used, creates a symbolic link for a file (default)

/h – Creates a hard link

/j – Creates a junction point

<NameofLink> – The name for the Symbolic link being created

<Target> – The relative or absolute path of the target

/? – Help

Third-party Tools:

Command line tools:

  • junction.exe – by Sysinternals  - Creates Junction Points and includes additional commands for displaying and deleting them. Runs on Windows XP and higher and Windows Server 2003 and higher.

display reparse point* info usage: junction.exe [-s] [-q] <file or directory>

-q – Don’t print error messages (quiet)

-s – Recurse subdirectories

create usage: junction.exe <junction directory> <junction target>

delete usage: junction.exe -d <junction directory>

*Reparse points are redirections in the Windows file system using user-defined data in tags to identify and process files.

  • linkd.exe – Part of the Windows 2003 Resource Kit  - Creates and deletes junction points. (For Win2k, WinXP and Windows Server 2003)

create usage: linkd newdirname existingdirname

delete usage: linkd newdirname /D

Context Menu/Shell tools:

  • NTFS Linkelsdoerfer.name – Creates Hard Links and Hunction Points using drag and drop with the right mouse button. Works with Win2K (NTFS ver 5 or greater) and above.

GUI-based tools:

  • Junction Link MagicRekenwonder Software – GUI-based application to create, list, and remove Junction Points. Also lists Symbolic Links and Mount Points. Works with Win2K, XP, 2003, Vista, Windows Server 2008 and Windows 7.

Tutorials on creating and using Hard Links, Soft Links and Junction Points:

Daniel Einspanjer’s journal - How To Use Hardlinks And Junctions In Windows

The Developer’s TidbitWindows File Junctions, Symbolic Links and Hard Links

How-to GeekUsing Symlinks in Windows Vista

Jameser’s Tech TipsTip #37: Creating NTFS Hard Links in Windows XP

Jeff Wouters’s BlogMaking soft and symbolic links in Windows

Maxi-Pedia – Mklink in Windows

TechRepublicVista’s symbolic links feature saves navigating time

 

for more information.

Share
25. May 2011 · 1 comment · Categories: Networking · Tags: ,

This guide illustrates the concepts for tunneling VNC over SSH. VNC is a protocol that allows you to control a desktop from a remote computer and allows others to view or control your desktop from their computer. However, using VNC alone can be a security risk. Although VNC uses password encryption, the rest of the traffic is sent unencrypted.

SSH or Secure Shell, is a secure protocol with a feature called port forwarding that can be used to provide secure connections for VNC, as well as for POP3, SMTP, RDP, HTTP and other protocols. Using SSH port forwarding to secure connections is also known as SSH Tunneling. SSH tunneling creates a SSH tunnel to encapsulate unencrypted traffic (the payload protocol), such as VNC, over an encrypted SSH channel (the delivery protocol). In other words, using VNC with SSH port forwarding makes a port from one PC appear on another PC through a SSH connection, providing a secure path for the VNC traffic.

A practical use of SSH tunneling with local and remote port forwarding would be to securely exchange the desktops between two PCs using the VNC protocol. Setting up the SSH sessions can be accomplished for both PCs from the same SSH client PC. Another use for SSH tunneling not covered in this guide is to bypass firewalls that block certain ports, such as port 80, which are often blocked to prevent users from accessing the Internet using company computers (see related article – Using SSH to secure Internet connections).

SSH Port Forwarding Summary

In the following definitions and examples, a remote machine is defined as the PC with the SSH server. All commands in the examples here are executed from the SSH client machine (192.168.1.1). Although both forwarded and local ports may be the same, the examples shown use different port numbers for clarification.

Two types of SSH port forwarding are: (1) local port forwarding, and (2) remote port forwarding, with local port forwarding being the more common. Another type of SSH port forwarding not covered in this guide, is Dynamic port forwarding (see Using SSH to secure Internet connections).

1.  Local port forwarding –  A port from the client PC is forwarded to the remote PC. A connection to this port enables data to be sent bidirectionally over the SSH connection between the client and remote PC. See Fig 1.

2. Remote port forwarding – This is a reverse of local port forwarding.  A port from the remote PC is forwarded to the client PC.  A connection to this port enables data to be sent bidirectionally over the SSH connection between the client and remote PC. See Fig 2.

Other points:

  • Ports may be forwarded to multiple hosts on a single connection or by using multiple SSH connections.
  • Other computers on the Internet are prevented from connecting to forwarded ports unless enabled with the “-g” flag.
  • VNC servers must allow loopback connections since clients are seen as local connections.
  • To connect PCs over the Internet, port 22 must be forwarded for SSH on the router.
  • Port numbers from 0 to 1023 are privileged ports used by system processes to provide network services. For Unix and Unix-like operating systems, these processes can only execute with superuser privileges. It’s therefore best to avoid using ports under 1024 for local ports.

Local Port Forwarding for VNC

Figure 1 illustrates local port forwarding for a VNC session (click to enlarge) over a LAN. The client Windows PC has IP address 192.168.1.1 and the remote Linux PC has IP address 192.168.1.3.  The syntax for local port forwarding as used in this example:

ssh username@serverhost -L localport:host:remoteport

Note: The use of a Windows PC and Linux machine in the Figure 1 below is for illustration purposes only. The operating systems are irrelevant. What matters is that client PC has a SSH client and VNC viewer, and the remote machine has a SSH server and VNC server. 

Local Port Forwarding

Fig 1

To establish the SSH connection using local port forwarding, the following command can be entered into a command window on the client PC:

ssh user@192.168.1.3 -L 6999:localhost:5901
  • user@192.168.1.3 = SSH host to connect to
  • -L = Option to enable local port forwarding
  • 6999 = Port on the client PC
  • localhost = Host server to connect to (the remote PC, same as 127.0.0.1)
  • 5901 = Port on the remote host (forwarded from the client PC)

To connect to the VNC server, enter the following into the VNC viewer:

127.0.0.1:6999

or

localhost:6999

Remote Port Fowarding for VNC

Figure 2 illustrates remote port forwarding for a VNC session (click to enlarge) over a LAN. The client Windows PC has IP address 192.168.1.1 and the remote Linux PC has IP address 192.168.1.3. The syntax for remote port forwarding as used in this example:

ssh username@serverhost -R localport:host:remoteport

Note: The use of a Windows PC and Linux machine in the Figure 1 below is for illustration purposes only. The operating systems are irrelevant. What matters is that the the client PC has a SSH client and VNC server, and the remote PC has a SSH server and VNC viewer. 

Remote Port Forwarding

Fig 2

To establish the SSH connection using remote port forwarding, the following command could be entered into a command window on the client PC:

ssh user@192.168.1.3 -R 6999:localhost:5901
  • user@192.168.1.3 = SSH host to connect to
  • -R = Option to enable remote port forwarding
  • 6999 =Port on the remote host
  • localhost = Host server to connect to (the client PC, same as 127.0.0.1)
  • 5901 = Port on client PC (forwarded from the remote PC)

(Add the “-v” option at the end of the command above to view debugging messages about SSH’s connection progress)

To connect to the VNC server, enter the following into the VNC viewer:

127.0.0.1:6999

or

localhost:6999
Share
11. May 2011 · 1 comment · Categories: Networking · Tags: ,

This guide demonstrates how to setup OpenSSH RSA public-key authentication for Windows (using OpenSSH v3.8.1p1-1) and Linux (using OpenSSH v5.3p1) PCs currently working with password authentication on a local network. Although the information for this guide was tested on PCs with WinXP and Lubuntu, it can be applicable for other versions of Linux and Windows. You will need physical access to both PCs.

rsakeys

Public-key Cryptography

Public-key cryptography uses of a pair of matching keys, a public key and a private key, which are created at the same time using a key generation utility (ssh-keygen.exe is the key generation utility used in OpenSSH). A public key can be known to anyone and is used to encrypt data. The only way to decrypt data encrypted with the public key is with the matching private key. Although the two keys are related, a private key can’t be created from its matching public key. Public-key cryptography is widely used for public-key authentication to enable secure logins to servers without passwords, and for digital or electronic signatures, which certifies the authenticity of data signed by the private key.

OpenSSH Public-key Authentication

OpenSSH can use either the RSA or DSA algorithms for public-key authentication. RSA stands for stands for Rivest, Shamir and Adleman, the last names of the MIT team members who developed it. DSA stands for Digital Signature Algorithm, a US Government standard proposed by the National Institute of Standards and Technology. Although there are arguments for and against using one or the other, RSA is often the preferred choice because of its verification speed and key strength. See What is better for GPG keys – RSA or DSA? for a discussion on on this topic.

The importance for using pubic key authentication can be summed up in this statement from the Ubuntu help pages: “If your SSH server is visible over the Internet, you should use public key authentication instead of passwords if at all possible. If you don’t think it’s important, try logging all of the malicious login attempts you get for the next week. My computer – a perfectly ordinary desktop PC – had over 4,000 attempts to guess my password and almost 2,500 break-in attempts in the last week alone. “

Steps for RSA Public-key Authentication

The following steps will setup RSA public-key authentication keys without a passphrase to enable automatic logins between Linux to Windows PCs on a local network. The instructions will be similar to setup public-key authentication on remote hosts, except that SSH port 22 (if using the default port) must be forwarded to access remote servers from behind a router. When creating keys without a passphrase, as in this guide, make sure to place the public key on trusted hosts as it’s possible to compromise the remote computer should your private key fall into the wrong hands.

From the Windows PC

Step 1 – Generate Public Keys for the Windows PC

On the Windows PC, open a CMD window and type in the following command and hit ENTER to create a RSA key of 2048-bits (the default). The -t option specifies the type of key:

ssh-keygen -t rsa

Note: If you get a command is not recognized error, your path is incorrect. In this case, change to the bin folder where OpenSHH is installed to run the command.

When the command is executed, you will be prompted for a location to save the keys, and then for a passphrase as shown below. Hit ENTER to accept the default locations and to set NO passphrase.

Output:

Generating public/private rsa key pair
Enter file in which to save the key (/home/username/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/username/.ssh/id_rsa
Your public key has been saved in /home/username/.ssh/id_rsa.pub

The public key will be saved as .ssh/id_rsa.pub and your private key saved as .ssh/id_rsa in your home folder. The home directory is setup for users when OpenSSH was installed and configured.

Step 2 – Transfer Public Key to Linux PC

For the public key to be usable, it must be appended to the .ssh/authorized_keys file on the Linux computer and/or on other hosts you log into. If the authorized_keys file does not exist in your Linux computer’s home .ssh directory, create it. The public key (ending in .pub) can be copied to /home/username/.ssh/otherkeys on the Linux computer using a USB drive, another medium, Windows file sharing, or SCP. Make sure to only copy the key and not move it.

After transferring the public key, at the Linux PC, open a terminal window and navigate to the .ssh folder in your home directory, and append the public key using the command below:

cat otherkeys/id_rsa.pub >> authorized_keys

Note: the key can also be cut and pasted into the authorized_keys file using a text editor

OR – copying the key if the authorized_keys file is empty or not present

To remotely copy the public key to the Linux PC using SCP, enter the following in a command window. Note that there is no command for appending to a file using SCP. You will be asked for your password to use SCP remotely from the Windows PC:

# scp ~/.ssh/id_rsa.pub user@192.168.x.x:.ssh/authorized_keys

Step 3 – Edit sshd_config

Open a command window and try to authenticate automatically to the Linux PC from the Windows PC using SSH. Make sure the SSH server was started on the Linux PC. It should work. If not, continue with the rest of this step and then recheck.

To troubleshoot the SSH public-key cryptography authentication processes, you can use the verbose option switch (-v) in the ssh command when logging in:

ssh -v user@192.168.x.x

If authentication didn’t work, goto the Linux PC and check that the permissions of the .ssh directory are set to octal 700. If not, use the following command from the Linux PC to change it:

# chmod 700 ~/.ssh/authorized_keys

If error messages were observed relating to the known_hosts file, find and delete the entries in the known_hosts file in the user .ssh directory of the Windows PC.  The entries causing the errors will be numbered in the error message. After deleting the offending entry in the known_hosts file, test again to determine whether you can log onto the Linux PC without using a password.

After verifying you can log into the Linux PC without using a password, password authentication will still work should RSA not work for any reason, which is a security vulnerability. Password authentication can be turned off completely by changing the following entries in the etc/ssh/sshd_config file on the Linux PC. To use RSA authentication exclusively, make the following changes to the sshd_config to force public-key authentication and disable password authentication:

PasswordAuthentication no
PubkeyAuthentication yes
RSAAuthentication yes

After saving the file, restart the Linux PC SSH server using sudo /etc/init.d/ssh restart from a terminal on the Linux PC before logging in.

____________________________________________________________________________________

From the Linux PC

The steps are essentially the same as the previous steps with a few minor differences from the previous instructions

Step 1 – Generate Public Keys for the Linux Computer

From the Linux PC, open a terminal and type in the following command and hit ENTER to create a RSA key of 2048-bits (the default). The -t option specifies the type of key:

ssh-keygen -t rsa

When the command is executed, you will be prompted for a location to save the keys, and then for a passphrase as shown below. Hit ENTER to accept the default locations and to set NO passphrase.

Output:

Generating public/private rsa key pair
Enter file in which to save the key (/home/username/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/username/.ssh/id_rsa
Your public key has been saved in /home/username/.ssh/id_rsa.pub

The public key will be saved as .ssh/id_rsa.pub and your private key saved as .ssh/id_rsa in your home folder.

Step 2 – Transfer Public Key to Windows PC

For the public key to be usable, it must be appended to the .ssh/authorized_keys file on the Windows computer, other Linux PCs, and/or other hosts you log into. If the authorized_keys file does not exist in the user’s Windows .ssh directory, create it. The public key (ending in .pub) can be copied to \home\username\.ssh\otherkeys on the Windows computer using a USB drive, another medium, file sharing, or SCP. Make sure to only copy the key and not move it.

After transferring the public key, at the Windows PC, navigate to the .ssh folder in your home directory, and append the public key to the authorized_keys file using the command below:

copy /b authorized_keys + otherkeys\id_rsa.pub authorized_keys

Note: the key can also be cut and pasted into the authorized_keys file using a text editor

OR – if the authorized_keys file is empty or not present

To remotely copy the public key from the Linux PC to the Windows PC with SCP, enter the following in a terminal window. Note that there is no command for appending to a file using SCP. You will be asked for your password to use SCP remotely from the Linux PC:

# scp ~/.ssh/id_rsa.pub user@192.168.x.x:.ssh/authorized_keys

Step 3 – Edit sshd_config

In a terminal window try to log into the Windows PC with public-key authentication using SSH. Make sure the SSH server was started on the Windows PC. It should work. If not, continue with the rest of this step and then recheck.

To troubleshoot the SSH public-key cryptography authentication processes, you can use the verbose option switch (-v) in the ssh command as follows when logging in:

ssh -v user@192.168.x.x

If error messages errors were observed relating to the known_hosts file, find and delete those entries in the known_hosts file in the user .ssh directory in the Linux PC before continuing. The entries causing the errors will be numbered in the error message.

After deleting the offending entry in the known_hosts file, test again to determine whether you can log onto the Windows PC without using a password.

After verifying you can log into the Windows PC without using a password, password authentication will still work should RSA not work for any reason, which is also a security vulnerability. Password authentication can be turned off completely by changing the following entries in the OpenSSH\etc\sshd_config file on the Windows PC. To use RSA authentication exclusively, make the following changes to the sshd_config file to force public-key authentication and disable password authentication:

Note: If you still are unable to log in with pubic-key authentication at this point, do not make the following changes to the sshd_config file to force public-key authentication since you may need to login locally using your password with tools such as WinSCP. See below troubleshooting procedures:

StrictModes no
PasswordAuthentication no
PubkeyAuthentication yes
RSAAuthentication yes

After saving the sshd_config file, restart the Windows PC SSH server first by stopping it using net stop opensshd and then restarting it using net start opensshd in a command window on the Windows PC to allow the config file to take effect before logging in.

If public-key authentication still doesn’t work, the most likely cause is that that the read/write/access permissions for the .ssh directory or for OpenSSH for the Windows PC are incorrect. See the below troubleshooting procedures below for further information.

Troubleshooting Windows OpenSSH server issues:

File permissions issues are a notorious problem for getting pubic-key authentication to work for OpenSSH on Windows. It’s probably the most confusing and most difficult issue to resolve. After much research and troubleshooting, I got it to work following this source from osdir.com. However, it’s uncertain whether it was one, all, or a combination of the suggestions that fixed the problem. In any case, below is a summary of the suggestions and how they were followed.

The tool used to change file permissions for the instructions below was WinSCP, with 127.0.0.1 as the host name and SFTP as the protocol (see screenshot below).

WinSCP session screen

Permission changes were made using the properties window as shown in the screenshot below:

winscp properties

Here are the suggestions from osdir.com and how each was followed. Suggestions are preceded by an asterisk “*” and how the suggestions were followed are in bold :

*Change ownership of OpenSSH folder/subfolders to Administrators using Windows Explorer – Performed this for the folder and all subfolders using WinSCP.

*Grant Administrators full control of the OpenSSH folder – Same as above using Octal 0700

*From a command prompt, type “cacls c:\program files\openssh /t /e /c /g Administrators:F” * – Performed this for the c:\ssh folder, which was the OpenSSH folder on my PC.

Edit sshd_config file and set StrictModes to “no” –  Changed the StrictModes entry to “no” and saved the file

*Under the user’s profile, grant Administrators (and only Administrators) full control of the .ssh folder and files – Did this for all folders and files for .ssh in the user directory (C:\Documents and Settings\user\.ssh).

*If this folder does not exist, it can be created by establishing an SSH connection to another box – Skipped. The .ssh file already existed

*On clients only, copy the private RSA key to the local .ssh folder and name it “id_rsa” - Skipped. The private keys already existed.

*Copy the client’s public RSA key to the desired server(s) by adding it to an “authorized_keys” text file located under the server’s .ssh folder - Skipped. Done previously.

* To use publickey authentication, use the SSH command line switch “-o PreferredAuthentications=publickey”. Alternately, you can modify the ssh_config file to make this the default – Skipped.

If the above instructions worked:

Decide whether to use RSA authentication exclusively. If so, edit the sshd_config file per the instructions above.

Note: many instructions on various web sites suggest copying public keys to the user’s .ssh directory on the server. If you do, make sure to place them in a separate folder such as a otherkeys folder or another name such as username_key since existing public keys (id_rsa.pub) will be overwritten if multiple PCs are used to access the same machine. 

Share
03. May 2011 · Write a comment · Categories: Networking · Tags: ,

VNC is one of many protocols used to share desktops between Linux and Windows PCs (see this Wikipedia entry for a comparison of various remote desktop software packages). Although a number of VNC (Virtual Network Computing) servers include some type of built-in encryption, many do not. In addition, many VNC client/viewers tend to be basic so they generally don’t include any built-in encryption support. For both aforementioned situations, SSH tunneling can be used to secure sessions between VNC servers and even the most basic VNC client/viewers, regardless of any built-in protocols. However, using SSH to encrypt VNC communications can be a manually intensive and multi-step process requiring starting up SSH and VNC servers and configuring SSH and VNC clients for local or remote port forwarding.

An Enhanced TightVNC Viewer, SSVNC, is free multi-platform SSH/SSL VNC viewer that automates this process. It’s also compatible with a wide range of VNC servers. In fact, the SSVNC web site states that SSVNC works with nearly any VNC Server host running SSHD and those running an SSL tunnel, including VeNCrypt SSL/TLS and Vino/ANONTLS encryption extensions to VNC on Unix, Mac OS X, and Windows. SSVNC also works as a regular VNC viewer without encryption as well. SSVNC is available from the Ubuntu repositories and installable through the Synaptic Package Manager or apt-get, while Unix, MacOS, and Windows versions are available from the SSVNC web site and through Sourceforge.net.

SSVNC Viewer

For this post, SSVNC (using the precompiled binaries) was tested on a Windows XP machine connected to TightVNC and X11VNC servers running on a Lubuntu machine and SSH tunneling enabled through the SSVNC viewer. Although this viewer is packed with features, it worked quickly and easily. Its many features are listed on the SSVNC web site.

viewer interface

Related Information:

VNC on Linux

 

Share
01. May 2011 · Write a comment · Categories: Linux · Tags:

Joshua Price regularly contributes useful, easy-to-understand information on Linux at MakeTechEasier.com. His articles should be of interest any Linux user, regardless of experience level. Below are the links to some of his useful and interesting Linux-related articles at MakeTechEasier.com. Be sure to check out his other Linux-related articles there as well.

Bash command-line

Become an APT guru

Beginner’s Guide to Git

Mastering the Bash History

8 Useful and Interesting Bash Prompts

More Useful and Interesting Bash Prompts 

The Beginner Guide to Writing Linux Shell Scripts

Making The Linux Command Line A Little Friendlier

From Noob to Ninja – Your Guide to Mastering Linux

How to Multitask at the Linux Command Line with Screen

 

Share

Lynx is a text-only web browser originally designed to run on UNIX, but today it also runs on Linux, VMS, MacOS, Windows and other platforms. It was initially developed by a team of University of Kansas students in 1992 for distributing information on a campus-wide information system and as a Gopher client, but it quickly became popular with visually impaired users because of its text-to-speech friendly interface. Although less used today as part of text-to-speech translating systems due to the technological improvements in screen readers, Lynx is still developed, useful, and it’s included as part of many Linux and UNIX distributions. Lynx is licensed under the GNU General Public License.

Some uses for Lynx :

  • Reading documentation or downloading files in a text-based environment
  • To access websites without graphical displays
  • For use on low bandwidth Internet connections
  • For use on older and slower computer hardware
  • For fast, safe browsing of text-based web sites
  • Search Engine View Emulation
  • Incorporating into scripts and to automate tasks

Advantages of Lynx:

  • Fast, free, and safe
  • Handles cookies
  • Has many options
  • Multilingual
  • No ads


Quick start Lynx info:

Hint: To start browsing, press “g” on the keyboard, enter a website URL and press enter. For help on additional commands, see the sites below:

Lynx: The text browser (what it is, how to use it, where to get it)

Lynx Browser (quick info about Lynx)

Lynx Help for Beginners (quick start info for newbies)

Lynx Users Guide v2.8.7 (full manual)

 

 

Other text-based browsers:

Links –  Runs on Linux, Unix, OS/2 and Windows. Renders frames and tables

ELinks – Linux browser based on Links. Renders frames and tables

W3M –  Linux browser that can render frames and tables

 

Share

This guide illustrates a quick method to add pre-compiled PDCurses to MingW on WinXP and verifying the installation. From time to time, it may be necessary to compile source code in Windows where the NCurses or Curses library is required, and often PDCurses can be used as a substitute. Since PDCurses isn’t included with a MingW installation it must be installed separately. Although other tutorials for installing PDCurses are available, they may contain outdated information, require compiling source code, use overly complex installation instructions, or are specific for various IDEs. This guide uses pre-compiled PDCurses version 3.4 and MingW GCC version 4.50. You can type “gcc –version” (without quotes) at the msys prompt to identify your gcc version.

Background

PDCurses is the multi-platform, public domain implementation of the terminal display library NCurses. NCurses (New Curses) is an implementation of Curses (a play on the term cursor optimization), both of which are terminal control libraries for UNIX and UNIX-like systems. Although not identical, PDCurses, NCurses, and Curses enable programmers to add mouse support, screen painting, colors, key-mapping, windows, and more to text-based applications without regard to the terminal type. An example of PDCurses in use is shown here. MingW (Minimalist GNU for Windows) is a minimal Open Source programming environment for developing Windows native applications not requiring 3rd-party Runtime DLLs. However, MingW does utilize some Microsoft DLLs provided by the Microsoft C runtime library. It includes the GNU Compiler Collection (GCC) and associated tools, the GNU binutils.

Steps

Download the PDCurses version 3.4 file Download pdc34dllw.zip (86.9 KB) from Sourceforge.com and unzip it. This version is the Win32 DLL for console with Unicode. Copy the extracted files to the following folders:

  • pdcurses.lib to MingW’s “/lib” folder
  • cursors.h and panels.h to MingW’s “/include” folder
  • pdcures.dll to MingW’s “/bin” folder

Test

Example command using PDCurses to compile the file checkthis.c:

gcc checkthis.c -o checkthis -lpdcurses

If the following code compiles, PDCurses is installed correctly.


/*  checkthis.c  */

#include <curses.h>

int main()

{

initscr();

wclear(stdscr);

printw("hello world\n");

wrefresh(stdscr);

system("pause");

endwin();

}
Share
26. March 2011 · 1 comment · Categories: TechBits · Tags:

After changing in the default application for text files to another application, text files opened normally with a double-click, but the icon didn’t change to that of the associated text application. In fact, no matter what was tried, including several changes in the default text  file program through various methods and some registry hacks, the icon stayed the same. Furthermore, sometime during this process, the context menu entry for “New ->Text Document” disappeared entirely.

context menu

The problem was easily fixed by merging a .reg file into the registry to restore the default association for text file extensions. The .reg file was available from DougKnox.com. In fact, the same page provides .reg files to restore 30 other file extension defaults for Windows® XP, so it’s a good resource to know about.

Another excellent resource is a TechBuzz article, How to Restore Default File Extension Type Associations? The article explains file associations, how to change them, and how and where to get resources to restore the default associations for WinXP, Vista, and Win7.

Finally, for a change in XP’s registry to take effect, the machine usually must be rebooted. However, a freeware  program, Explorestart v1.00, allows you to make a change in the registry and check the effect of the change without rebooting. Explorestart V1.00 works for Windows 98, Windows ME, Windows 2000, and Windows XP.

Share

Bad Behavior has blocked 604 access attempts in the last 7 days.