Archive for February, 2008

Using OpenSSH keys with Server

February 27, 2008 Leave a comment

You can determine which versions of the ssh protocol an ssh server supports by examining the service banner. The service banner includes both the remote protocol version and the remote software version.

telnet ssh_server 22

SSH-1.5-remote_software_version (supports ssh protocol 1 only)
SSH-1.99-remote_software_version (supports ssh protocols 1 and 2)
SSH-2.0-remote_software_version (supports ssh protocol 2 only)

ssh protocol 2:

1. Create a DSA or RSA key named foo. As of version 3.0 of the server includes support for RSA keys.
$ cd ~/.ssh
$ ssh-keygen -t dsa -f foo

2. Convert the DSA or RSA key into “SECSH Public Key File Format,” the format used on an server.
$ ssh-keygen -e -f foo >

3. Copy the file to the server.
$ scp user@ssh.com_host:.ssh2

If the remote server only allows ssh protocol 2, you may receive the following errors:

scp: warning: Executing scp1 compatibility.
scp: FATAL: Executing ssh1 in compatibility mode failed (Check that scp1 is in your PATH).
lost connection

Use sftp instead to transfer the key:

$ sftp user@ssh.com_host
put .ssh2

4. Add the appropriate ~/.ssh2/authorization file entry in the server.
$ ssh user@ssh.com_host ‘echo “key” >> .ssh2/authorization’

5. Login to the server using the foo identity.
$ ssh -o IdentityFile2=~/.ssh/foo user@ssh.com_host

ssh protocol 1:

1. Create an RSA1 key.
$ cd ~/.ssh
$ ssh-keygen -t rsa1

2. Append the ~/.ssh/ file to the ~/.ssh/authorized_keys file on the server.
$ cat ~/.ssh/ | ssh remote_server “cat – >> ~/.ssh/authorized_keys”

Note: Any server only allowing ssh protocol 1 should be upgraded, as usage of ssh protocol 1 itself is not recommended.

%d bloggers like this: