ssh.rst
author Oleksandr Gavenko <gavenkoa@gmail.com>
Thu, 25 Apr 2024 22:33:14 +0300
changeset 2593 f0ab046a080f
parent 2585 9b1f7faff31c
permissions -rw-r--r--
Installing Android SDK from command line tools.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1334
9bf0d5a1f0cf Include common header with quick links.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1032
diff changeset
     1
.. -*- coding: utf-8; -*-
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     2
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     3
===========
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     4
 SSH/sshd.
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     5
===========
1032
4decc3e00bb6 Fix coding and contents.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1002
diff changeset
     6
.. contents::
1904
78357d58b7ab Fix RST syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1858
diff changeset
     7
   :local:
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     8
1385
acb36dfe5d09 Debugging ssh client.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1384
diff changeset
     9
Debugging ssh client.
acb36dfe5d09 Debugging ssh client.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1384
diff changeset
    10
=====================
acb36dfe5d09 Debugging ssh client.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1384
diff changeset
    11
::
acb36dfe5d09 Debugging ssh client.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1384
diff changeset
    12
acb36dfe5d09 Debugging ssh client.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1384
diff changeset
    13
  $ ssh -vvv ...
acb36dfe5d09 Debugging ssh client.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1384
diff changeset
    14
2397
320b2c43529b Disabling pubkey.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2228
diff changeset
    15
Maintaining key pair
320b2c43529b Disabling pubkey.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2228
diff changeset
    16
====================
1957
cd6f239a8dd3 Check available key types.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1956
diff changeset
    17
cd6f239a8dd3 Check available key types.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1956
diff changeset
    18
Check available key types::
cd6f239a8dd3 Check available key types.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1956
diff changeset
    19
cd6f239a8dd3 Check available key types.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1956
diff changeset
    20
  $ ssh -Q key
cd6f239a8dd3 Check available key types.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1956
diff changeset
    21
cd6f239a8dd3 Check available key types.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1956
diff changeset
    22
Generate keys::
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    23
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    24
  $ ssh-keygen -t dsa     # for DSA
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    25
  $ ssh-keygen -t rsa     # for RSA
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    26
  $ ssh-keygen -t dsa -C comment     # put own comment instead user@host
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    27
  $ ssh-keygen -t dsa -f my_dsa_key  # store priv key under my_dsa_key
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    28
                                     # and pub key under my_dsa_key.pub
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    29
2520
787ff2658636 Show fingerprint.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2408
diff changeset
    30
  ssh-keygen -f my.key
787ff2658636 Show fingerprint.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2408
diff changeset
    31
2408
c19423f2e7ee Recover pub key from priv.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2397
diff changeset
    32
Recover pub key from priv::
c19423f2e7ee Recover pub key from priv.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2397
diff changeset
    33
2520
787ff2658636 Show fingerprint.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2408
diff changeset
    34
  ssh-keygen -y -f ~/.ssh/id_dsa >~/.ssh/id_dsa.pub
787ff2658636 Show fingerprint.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2408
diff changeset
    35
787ff2658636 Show fingerprint.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2408
diff changeset
    36
Show fingerprint::
787ff2658636 Show fingerprint.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2408
diff changeset
    37
787ff2658636 Show fingerprint.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2408
diff changeset
    38
  ssh-keygen -l -f ~/.ssh/id_dsa
2585
9b1f7faff31c -lvf for ssh-keygen
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2555
diff changeset
    39
  ssh-keygen -lvf ~/.ssh/id_dsa
2538
1f827ee55f7c list fingerprints of the server pub keys
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2520
diff changeset
    40
  ssh-keygen -E md5 -l -f ~/.ssh/id_dsa
2408
c19423f2e7ee Recover pub key from priv.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2397
diff changeset
    41
c19423f2e7ee Recover pub key from priv.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2397
diff changeset
    42
Change passphrase of priv key::
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    43
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    44
  $ ssh-keygen -p -N "newphrase" -P "oldphrase" -f ~/.ssh/id_dsa
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    45
2555
70383fa8bf12 About copying SSH pubkey.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2554
diff changeset
    46
To copy your public key to a remote host (for automatic login by a pubkey authentication)::
1858
c6dc48292ee8 Coping and deleting public keys.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1680
diff changeset
    47
2555
70383fa8bf12 About copying SSH pubkey.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2554
diff changeset
    48
  $ ssh-copy-id $user@$host
1858
c6dc48292ee8 Coping and deleting public keys.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1680
diff changeset
    49
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    50
  $ ssh $user@$host cat ">>" "~/.ssh/authorized_keys" <~/.ssh/id_rsa.pub
2538
1f827ee55f7c list fingerprints of the server pub keys
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2520
diff changeset
    51
1f827ee55f7c list fingerprints of the server pub keys
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2520
diff changeset
    52
Dealing with server pubkeys
1f827ee55f7c list fingerprints of the server pub keys
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2520
diff changeset
    53
===========================
1f827ee55f7c list fingerprints of the server pub keys
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2520
diff changeset
    54
2555
70383fa8bf12 About copying SSH pubkey.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2554
diff changeset
    55
To remove a host fingerprint from a local ``known_hosts`` (if you changed a server pubkey or changed
70383fa8bf12 About copying SSH pubkey.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2554
diff changeset
    56
a server)::
70383fa8bf12 About copying SSH pubkey.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2554
diff changeset
    57
70383fa8bf12 About copying SSH pubkey.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2554
diff changeset
    58
  $ ssh-keygen -R hostname
70383fa8bf12 About copying SSH pubkey.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2554
diff changeset
    59
  $ ssh-keygen -R hostname -f ~/.ssh/known_hosts
70383fa8bf12 About copying SSH pubkey.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2554
diff changeset
    60
2538
1f827ee55f7c list fingerprints of the server pub keys
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2520
diff changeset
    61
Each SSH server keeps a single priv key, sharing a common pub key with all clients. It is an
1f827ee55f7c list fingerprints of the server pub keys
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2520
diff changeset
    62
identity of the server and upon a new connection you are asked to trust this pub key. After
1f827ee55f7c list fingerprints of the server pub keys
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2520
diff changeset
    63
accepting the pub key it is written to ``~/.ssh/known_hosts``.
1f827ee55f7c list fingerprints of the server pub keys
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2520
diff changeset
    64
1f827ee55f7c list fingerprints of the server pub keys
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2520
diff changeset
    65
To list advertized pub keys by a server (``-H`` is host hashing/hiding host name)::
1f827ee55f7c list fingerprints of the server pub keys
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2520
diff changeset
    66
1f827ee55f7c list fingerprints of the server pub keys
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2520
diff changeset
    67
  ssh-keyscan $HOST
1f827ee55f7c list fingerprints of the server pub keys
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2520
diff changeset
    68
  ssh-keyscan -H $HOST
1f827ee55f7c list fingerprints of the server pub keys
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2520
diff changeset
    69
1f827ee55f7c list fingerprints of the server pub keys
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2520
diff changeset
    70
To list fingerprints of the server pub keys::
1f827ee55f7c list fingerprints of the server pub keys
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2520
diff changeset
    71
1f827ee55f7c list fingerprints of the server pub keys
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2520
diff changeset
    72
  ssh-keygen -lf <(ssh-keyscan $HOST 2>/dev/null)
1f827ee55f7c list fingerprints of the server pub keys
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2520
diff changeset
    73
1f827ee55f7c list fingerprints of the server pub keys
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2520
diff changeset
    74
To ensure MD5 output format (which is usually displayed with vast majority of existing SSH
1f827ee55f7c list fingerprints of the server pub keys
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2520
diff changeset
    75
clients)::
1f827ee55f7c list fingerprints of the server pub keys
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2520
diff changeset
    76
1f827ee55f7c list fingerprints of the server pub keys
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2520
diff changeset
    77
  ssh-keygen -E md5 -lf <(ssh-keyscan $HOST 2>/dev/null)
1f827ee55f7c list fingerprints of the server pub keys
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2520
diff changeset
    78
2397
320b2c43529b Disabling pubkey.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2228
diff changeset
    79
Disabling pubkey
320b2c43529b Disabling pubkey.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2228
diff changeset
    80
================
320b2c43529b Disabling pubkey.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2228
diff changeset
    81
::
320b2c43529b Disabling pubkey.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2228
diff changeset
    82
320b2c43529b Disabling pubkey.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2228
diff changeset
    83
  ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no user@host
320b2c43529b Disabling pubkey.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2228
diff changeset
    84
2538
1f827ee55f7c list fingerprints of the server pub keys
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2520
diff changeset
    85
Shell login
1f827ee55f7c list fingerprints of the server pub keys
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2520
diff changeset
    86
===========
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    87
::
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    88
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    89
  $ ssh $user@$host
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    90
  $ ssh $user@$host:$port
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    91
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    92
  $ ssh -i ~/.ssh/my_dsa_key $user@$host
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    93
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    94
or::
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    95
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    96
  $ ssh -l $user $host
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    97
  $ ssh -l $user $host:$port
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    98
2397
320b2c43529b Disabling pubkey.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2228
diff changeset
    99
X11 forwarding
320b2c43529b Disabling pubkey.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2228
diff changeset
   100
==============
1384
9698523dd263 X11 forwarding.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1383
diff changeset
   101
9698523dd263 X11 forwarding.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1383
diff changeset
   102
Enable X11 forwarding on remote host in ``~/.ssh/config`` or ``/etc/ssh_config``::
9698523dd263 X11 forwarding.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1383
diff changeset
   103
9698523dd263 X11 forwarding.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1383
diff changeset
   104
  X11Forwarding yes
9698523dd263 X11 forwarding.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1383
diff changeset
   105
9698523dd263 X11 forwarding.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1383
diff changeset
   106
then login to this host by::
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   107
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   108
  $ ssh -X $user@$host
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   109
1384
9698523dd263 X11 forwarding.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1383
diff changeset
   110
or by using trusted X11 forwarding::
9698523dd263 X11 forwarding.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1383
diff changeset
   111
9698523dd263 X11 forwarding.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1383
diff changeset
   112
  $ ssh -Y $user@$host
9698523dd263 X11 forwarding.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1383
diff changeset
   113
1386
864237ce5f1b X11Forwarding does not work with OpenSSH under Cygwin
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1385
diff changeset
   114
See:
864237ce5f1b X11Forwarding does not work with OpenSSH under Cygwin
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1385
diff changeset
   115
2228
837f1337c59b Removed indentation that compiled into <blockquote>.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1957
diff changeset
   116
http://x.cygwin.com/docs/faq/cygwin-x-faq.html#q-ssh-no-x11forwarding
837f1337c59b Removed indentation that compiled into <blockquote>.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1957
diff changeset
   117
  X11Forwarding does not work with OpenSSH under Cygwin
1384
9698523dd263 X11 forwarding.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1383
diff changeset
   118
2397
320b2c43529b Disabling pubkey.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2228
diff changeset
   119
Multiply private keys
320b2c43529b Disabling pubkey.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2228
diff changeset
   120
=====================
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   121
2397
320b2c43529b Disabling pubkey.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2228
diff changeset
   122
``ssh`` tries to use all provided keys::
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   123
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   124
  $ ssh -i ./priv1 -i ./priv2 $user@$host
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   125
2397
320b2c43529b Disabling pubkey.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2228
diff changeset
   126
Alternatively place them to ``~/.ssh/config``::
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   127
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   128
  Host *
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   129
  IdentityFile ~/.ssh/identity # standard search path for protocol ver. 1
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   130
  IdentityFile ~/.ssh/id_dsa   # standard search path for RSA key protocol ver. 2
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   131
  IdentityFile ~/.ssh/id_rsa   # standard search path for DSA key protocol ver. 2
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   132
  IdentityFile ~/.ssh/my_dsa
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   133
  IdentityFile ~/.ssh/another_dsa
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   134
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   135
or per host private key::
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   136
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   137
  Host host1                   # alias, that user provide at CLI
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   138
  HostName host1.example.com   # real host name to log into
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   139
  User iam
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   140
  IdentifyFile ~/.ssh/iam_priv_dsa
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   141
  Host host2                   # alias, that user provide at CLI
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   142
  HostName 192.168.1.2         # real host IP to log into
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   143
  User admin
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   144
  IdentifyFile ~/.ssh/admin_priv_dsa
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   145
2397
320b2c43529b Disabling pubkey.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2228
diff changeset
   146
Installing sshd on Cygwin
320b2c43529b Disabling pubkey.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2228
diff changeset
   147
=========================
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   148
1904
78357d58b7ab Fix RST syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1858
diff changeset
   149
* Install base packages and openssh.
1954
307ce848ea6a Update instruction for sshd under Cygwin.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1912
diff changeset
   150
* Create Windows user and set its password.
1904
78357d58b7ab Fix RST syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1858
diff changeset
   151
* Recreate /etc/passwd::
78357d58b7ab Fix RST syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1858
diff changeset
   152
78357d58b7ab Fix RST syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1858
diff changeset
   153
    $ mkpasswd -l -u user >>/etc/passwd
78357d58b7ab Fix RST syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1858
diff changeset
   154
78357d58b7ab Fix RST syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1858
diff changeset
   155
  or::
78357d58b7ab Fix RST syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1858
diff changeset
   156
78357d58b7ab Fix RST syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1858
diff changeset
   157
    $ mkpasswd -l >/etc/passwd
78357d58b7ab Fix RST syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1858
diff changeset
   158
78357d58b7ab Fix RST syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1858
diff changeset
   159
* Register sshd::
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   160
1904
78357d58b7ab Fix RST syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1858
diff changeset
   161
    $ mkdir -p /home/user
78357d58b7ab Fix RST syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1858
diff changeset
   162
    $ ssh-host-config -y
78357d58b7ab Fix RST syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1858
diff changeset
   163
78357d58b7ab Fix RST syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1858
diff changeset
   164
* Start::
78357d58b7ab Fix RST syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1858
diff changeset
   165
78357d58b7ab Fix RST syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1858
diff changeset
   166
    $ net start sshd
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   167
1904
78357d58b7ab Fix RST syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1858
diff changeset
   168
  or::
78357d58b7ab Fix RST syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1858
diff changeset
   169
78357d58b7ab Fix RST syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1858
diff changeset
   170
    $ cygrunsrv -S sshd
78357d58b7ab Fix RST syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1858
diff changeset
   171
78357d58b7ab Fix RST syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1858
diff changeset
   172
* Check from remote host::
78357d58b7ab Fix RST syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1858
diff changeset
   173
78357d58b7ab Fix RST syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1858
diff changeset
   174
    $ ssh $gygwin_host -l user
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   175
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   176
To stop service use::
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   177
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   178
  $ net stop sshd
1680
826133768ee5 connection closed fix.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1626
diff changeset
   179
  $ cygrunsrv -E sshd
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   180
1954
307ce848ea6a Update instruction for sshd under Cygwin.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1912
diff changeset
   181
To delete service::
307ce848ea6a Update instruction for sshd under Cygwin.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1912
diff changeset
   182
307ce848ea6a Update instruction for sshd under Cygwin.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1912
diff changeset
   183
  $ cygrunsrv -E sshd
307ce848ea6a Update instruction for sshd under Cygwin.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1912
diff changeset
   184
  $ cygrunsrv -R sshd
307ce848ea6a Update instruction for sshd under Cygwin.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1912
diff changeset
   185
1680
826133768ee5 connection closed fix.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1626
diff changeset
   186
If you have ``connection closed`` error check permission for ``/home/*/.ssh``
826133768ee5 connection closed fix.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1626
diff changeset
   187
directories. If you start service from ``user`` account - add write permission
826133768ee5 connection closed fix.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1626
diff changeset
   188
to ``/home/*/.ssh``. I fix by::
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   189
1680
826133768ee5 connection closed fix.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1626
diff changeset
   190
  $ rm -r /home/*/.ssh
826133768ee5 connection closed fix.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1626
diff changeset
   191
  cmd> icacls c:\opt\cygwin\home /t /grant:r cyg_server:(f)
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   192
1954
307ce848ea6a Update instruction for sshd under Cygwin.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1912
diff changeset
   193
In order to enable logging from ``sshd`` uncomment in ``/etc/ssh/sshd_config``::
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   194
1954
307ce848ea6a Update instruction for sshd under Cygwin.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1912
diff changeset
   195
  SyslogFacility AUTH
307ce848ea6a Update instruction for sshd under Cygwin.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1912
diff changeset
   196
  LogLevel INFO
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   197
1954
307ce848ea6a Update instruction for sshd under Cygwin.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1912
diff changeset
   198
and start syslogd from ``inetutils`` package (don't forget to restart
307ce848ea6a Update instruction for sshd under Cygwin.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1912
diff changeset
   199
``sshd``!)::
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   200
1954
307ce848ea6a Update instruction for sshd under Cygwin.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1912
diff changeset
   201
  $ /bin/syslogd-config
307ce848ea6a Update instruction for sshd under Cygwin.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1912
diff changeset
   202
  $ net start syslogd
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   203
1954
307ce848ea6a Update instruction for sshd under Cygwin.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1912
diff changeset
   204
Check ``/var/log/messages`` for logging messages.
1955
62735335fcef userauth_pubkey: key type ssh-dss not in PubkeyAcceptedKeyTypes
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1954
diff changeset
   205
62735335fcef userauth_pubkey: key type ssh-dss not in PubkeyAcceptedKeyTypes
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1954
diff changeset
   206
.. note::
62735335fcef userauth_pubkey: key type ssh-dss not in PubkeyAcceptedKeyTypes
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1954
diff changeset
   207
62735335fcef userauth_pubkey: key type ssh-dss not in PubkeyAcceptedKeyTypes
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1954
diff changeset
   208
   In order to allow pubkey login and to avoid error::
62735335fcef userauth_pubkey: key type ssh-dss not in PubkeyAcceptedKeyTypes
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1954
diff changeset
   209
62735335fcef userauth_pubkey: key type ssh-dss not in PubkeyAcceptedKeyTypes
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1954
diff changeset
   210
     userauth_pubkey: key type ssh-dss not in PubkeyAcceptedKeyTypes
62735335fcef userauth_pubkey: key type ssh-dss not in PubkeyAcceptedKeyTypes
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1954
diff changeset
   211
1956
5f39abb7d5b0 DSS keys are depricated at all
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1955
diff changeset
   212
   add ``PubkeyAcceptedKeyTypes *`` or ``PubkeyAcceptedKeyTypes=+ssh-dss`` to
5f39abb7d5b0 DSS keys are depricated at all
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1955
diff changeset
   213
   ``/etc/ssh/sshd_config`` but DSS keys are depricated at all.
1955
62735335fcef userauth_pubkey: key type ssh-dss not in PubkeyAcceptedKeyTypes
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1954
diff changeset
   214