Solution Resort

Learn, try and share…

Category: Linux (Page 2 of 2)

SSH Public / Private Key Setup

Create Public / Private key pairs

ssh-keygen -t [Type of the key]  -b [Number of bits in the key to create]

e.g. ssh-keygen -t rsa -b 4096

Copy public key to remote server

ssh-copy-id -i [path to public key] [username]@[host]

e.g. ssh-copy-id -i keys/



Public key is always associated with a user when it gets copied onto the remote server. The default location storing the keys is usually ~/[user]/.ssh/. All public keys are appended to the ~/[user]/.ssh/authorized_keys file.


Useful Linux Commands

Commonly used Linux commands.

//change permissions recursively on Directories:
find . -type d -exec chmod XXX {} ;

//change permissions recursively on Files:
find . -type f -exec chmod XXX {} ;

//extract .tar.gz file:
tar -zxvf [file].tar.gz


//switch user:
su [username]

//change owner of a directory recursively
chown -Rv [username] [somedir]

//change group of a directory recursively
chgrp -Rv [usergroup] [somedir]

//add a user and add to group
useradd -G [group-name] [username]

//add a group
groupadd [groupname]

//add an existing user to group
usermod -a -G [group name] [username]

//SSH into another server
ssh -i [path/to/private/keyfile] [username]@[ip]

//Find files / folders greater than a size
du -h / | grep ^[0-9.]*G
du -h /usr/ | grep ^[1-9][0-9][0-9][0-9]*M

Page 2 of 2

Powered by WordPress & Theme by Anders Norén