File: sdm-autokeys

package info (click to toggle)
sdm 0.4.0a-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 188 kB
  • ctags: 4
  • sloc: sh: 68; makefile: 66
file content (28 lines) | stat: -rwxr-xr-x 430 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/sh

filename="$1"

shift

if [ -n "$1" ]; then
  user="$1"
fi

shift

if [ -n "$1" ]; then
  type="$1"
else
  type="rsa"
fi

ssh-keygen -t $type -f $filename -N ""

mkdir -p /home/$user/.ssh/
cp $filename.pub /home/$user/.ssh/authorized_keys
chown -R /home/$user/.ssh/
chmod -R og-rwx /home/$user/.ssh/

echo -e "you should now edit the \
  /home/$user/.ssh/authorized_keys file to restrict login to \
  specific commands"