216 questions

223 answers


334 users

Welcome to OSSbible, where you can ask Open Source Products questions and receive answers from members of the community. OSSbible has very active & vibrant community members whose knowledge is unparalleled.

How to add ssh key to create user if user is not specified in server

0 votes
asked Dec 1, 2015 in Linux by Stuart (510 points)

1 Answer

+1 vote
Best answer
mkdir /home/username && useradd -d /home/username -s /bin/bash username && chown -R username:username /home/username/ && cd /home/username/ && cp /etc/skel/.bash* . && cp /etc/skel/.profile* .

su - username

mkdir .ssh && cd .ssh  && vim authorized_keys

add the key in authorized file

ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAi+nG6T1Onzfq/XVhrsjT1BnRnKyoSNdqlbNWZ7KL495JpUrq2rdfFBFKZyDbV5QTUuWZ4m1qXdE9O4b/4KM+Tx13Ym8IUrUJPk0ABAmHnXMAc4qjfO2+iAf1pntO12JmuCfShy2t8EzBq17RwHMl/Lrq28gvJotNn+M/Xkg2YxIUzSFX2+IVtxU/HQrVCkKaqSfspCb4FoAa5JEe/24HGoNtwZcy03rt6EgNR60R9mJw2IWM7pRdeR2NasVJJdzIUlrJq+WSxoePp1d9WWNBUBJbprrCOvzPOSOuGE6dxEhjPP4XvUz5CeHcEyLwaI4vRK4LO4OSET3LLEFMdAQQhw== rsa-key-20150202

chmod 400 authorized_keys

usermod -G sudo username

gpasswd -d username sudo -- if u want to remove sudo access

cat /etc/group  | grep sudo
answered Dec 1, 2015 by prithvi (2,660 points)
selected Dec 1, 2015 by Stuart

Related questions