fa486b7f83633b486ea9f0d9d57989918784cf9e
[ikiwiki.git] / docs / docs / newhandbook / sshserver / index.mdwn
1 #SSH Server on DragonFly
2
3 This document is very detailed so that a new user can be familiar with the environment.
4
5 If you try to ssh to a newly installed dfly from another system you will get this error
6
7
8     $ ssh root@172.16.50.62
9     ssh: connect to host 172.16.50.62 port 22: Connection refused
10
11 This is because sshd is not up and running on dfly.
12 At this point if you check /etc/ssh you will only have the following files
13
14
15     # ls /etc/ssh
16     blacklist.DSA-1024      blacklist.RSA-2048      ssh_config
17     blacklist.DSA-2048      blacklist.RSA-4096      sshd_config
18     blacklist.RSA-1024      moduli
19
20 You don't have any SSH host keys generated for the system yet!
21
22 When you start sshd for the first time it is best to start it through the <b>"/etc/rc.d/sshd"</b> script which will automatically generate the host keys. For this to work right you need to do the following steps
23
24 1) Enable sshd in rc.conf
25
26     #echo "sshd_enable=yes" >> /etc/rc.conf
27
28 2) Start the sshd server using the rc script
29
30
31     # /etc/rc.d/sshd start
32     Generating public/private rsa1 key pair.
33     Your identification has been saved in /etc/ssh/ssh_host_key.
34     Your public key has been saved in /etc/ssh/ssh_host_key.pub.
35     The key fingerprint is:
36     ........
37     Generating public/private dsa key pair.
38     Your identification has been saved in /etc/ssh/ssh_host_dsa_key.
39     Your public key has been saved in /etc/ssh/ssh_host_dsa_key.pub.
40     The key fingerprint is:
41     ........
42     Starting sshd.
43
44 Now if you go back and look in /etc/ssh you will find the SSH host key files too.
45
46
47     # ls /etc/ssh
48     blacklist.DSA-1024      moduli                  ssh_host_key.pub
49     blacklist.DSA-2048      ssh_config              ssh_host_rsa_key
50     blacklist.RSA-1024      ssh_host_dsa_key        ssh_host_rsa_key.pub
51     blacklist.RSA-2048      ssh_host_dsa_key.pub    sshd_config
52     blacklist.RSA-4096      ssh_host_key
53
54
55 At this point if you try to ssh to the dfly you will get the following error
56
57
58     $ ssh sgeorge@172.16.50.62
59     The authenticity of host '172.16.50.62 (172.16.50.62)' can't be established.
60     RSA key fingerprint is 46:77:28:c2:70:86:93:1a:23:32:5f:01:2c:80:de:de.
61     Are you sure you want to continue connecting (yes/no)? yes
62     Warning: Permanently added '172.16.50.62' (RSA) to the list of known hosts.
63     Permission denied (publickey).
64
65 This is because of the following configuration option in the default **"/etc/ssh/sshd_config"** file.
66
67
68     # To disable tunneled clear text passwords, change to no here!
69     # We disable cleartext passwords by default
70     PasswordAuthentication no
71
72 Change it to
73
74
75     PasswordAuthentication yes
76
77
78 and reload **sshd** configuration
79
80
81     # /etc/rc.d/sshd reload
82     Reloading sshd config files.
83
84 Nowyou can login to the dragonfly system as a normal user.
85
86     $ ssh sgeorge@172.16.50.62
87     sgeorge at 172.16.50.62's password:
88     Last login: Tue Oct 19 04:17:47 2010
89     Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994
90             The Regents of the University of California.  All rights reserved.
91
92     DragonFly v2.7.3.1283.gfa568-DEVELOPMENT (GENERIC.MP) #3: Thu Oct 14 12:01:24 IST 2010
93
94     ....
95
96 But if you try to login by SSH as root you will get the following error.
97
98     $ ssh root at 172.16.50.62
99     root at 172.16.50.62's password:
100     Permission denied, please try again.
101
102 If you investigate the log of the dragonfly system <b>"/var/log/auth.log"</b> you will find a line similar to
103
104
105     Oct 19 07:29:36 dfly-vmsrv sshd[17269]: Failed password for root from 172.16.2.0 port 56447 ssh2
106
107 even if you typed the right password for root.
108
109 It is because of the following configuration option in the default **"/etc/ssh/sshd_config"** file
110
111     # only allow root logins via public key pair
112     PermitRootLogin without-password
113
114 which allowes only SSH key based authentication as root.
115
116 If you change it to
117
118
119     PermitRootLogin yes
120
121 and reload **sshd** configuration
122
123     # /etc/rc.d/sshd reload
124     Reloading sshd config files.
125
126 you can login as **root**
127
128     $ ssh root@172.16.50.62
129     root at 172.16.50.62's password:
130     Last login: Fri Oct  8 12:22:40 2010
131     Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994
132             The Regents of the University of California.  All rights reserved.
133
134     DragonFly v2.7.3.1283.gfa568-DEVELOPMENT (GENERIC.MP) #3: Thu Oct 14 12:01:24 IST 2010
135
136     Welcome to DragonFly!
137     ......
138
139 Now in the **"/var/log/auth.log" ** you will find a line similar to
140
141
142     Oct 19 07:30:32 dfly-vmsrv sshd[17894]: Accepted password for root from 172.16.2.0 port 56468 ssh2
143
144
145 ##WARNING :
146 ** It is not advisable to allow Root Login with password especially if your System is connected to the Internet unless you use Very Strong Passwords. You could be a victim of [ssh password based brute force attacks](http://en.wikipedia.org/wiki/Password_cracking#Brute_force_attack). If you are victim of one such attack you can find entries like the following in your** ****"/var/log/auth.log file"****.
147
148     Oct 18 18:54:54 cross sshd[9783]: Invalid user maryse from 218.248.26.6
149     Oct 18 18:54:54 cross sshd[9781]: input_userauth_request: invalid user maryse
150     Oct 18 18:54:54 cross sshd[9783]: Failed password for invalid user maryse from 218.248.26.6 port 34847 ssh2
151     Oct 18 18:54:54 cross sshd[9781]: Received disconnect from 218.248.26.6: 11: Bye Bye
152     Oct 18 18:54:55 cross sshd[27641]: Invalid user may from 218.248.26.6
153     Oct 18 18:54:55 cross sshd[3450]: input_userauth_request: invalid user may
154     Oct 18 18:54:55 cross sshd[27641]: Failed password for invalid user may from 218.248.26.6 port 34876 ssh2
155     Oct 18 18:54:55 cross sshd[3450]: Received disconnect from 218.248.26.6: 11: Bye Bye
156     Oct 18 18:54:56 cross sshd[8423]: Invalid user admin from 218.248.26.6
157     Oct 18 18:54:56 cross sshd[3131]: input_userauth_request: invalid user admin
158     Oct 18 18:54:56 cross sshd[8423]: Failed password for invalid user admin from 218.248.26.6 port 34905 ssh2
159     Oct 18 18:54:56 cross sshd[3131]: Received disconnect from 218.248.26.6: 11: Bye Bye
160     Oct 18 18:54:57 cross sshd[7373]: Invalid user admin from 218.248.26.6
161     Oct 18 18:54:57 cross sshd[28059]: input_userauth_request: invalid user admin
162     Oct 18 18:54:57 cross sshd[7373]: Failed password for invalid user admin from 218.248.26.6 port 34930 ssh2
163     Oct 18 18:54:57 cross sshd[28059]: Received disconnect from 218.248.26.6: 11: Bye Bye
164     Oct 18 18:54:58 cross sshd[12081]: Invalid user admin from 218.248.26.6
165     Oct 18 18:54:58 cross sshd[22416]: input_userauth_request: invalid user admin
166     Oct 18 18:54:58 cross sshd[12081]: Failed password for invalid user admin from 218.248.26.6 port 34958 ssh2
167     Oct 18 18:54:58 cross sshd[22416]: Received disconnect from 218.248.26.6: 11: Bye Bye
168