git clone on Ubuntu 12

Apparently your keys get wiped everytime you log out? Resulting in:

Permission denied (publickey).

Follow step3 here to add it!

Also add this to your .bashrc to add it on start up.

# Add to your Bash config file
SSHAGENT=/usr/bin/ssh-agent
SSHAGENTARGS="-s"
if [ -z "$SSH_AUTH_SOCK" -a -x "$SSHAGENT" ]; then
    eval `$SSHAGENT $SSHAGENTARGS`
    trap "kill $SSH_AGENT_PID" 0
fi

#auto add key
ssh-add ~/.ssh/id_rsa
Advertisements

Additional SFTP access

Add new user. This will create the following:
– a new directory at /home/newuser/
– user and group called newuser

$ sudo adduser newuser

Edit /etc/ssh/sshd_config

#Subsystem sftp /usr/lib/openssh/sftp-server
Subsystem sftp internal-sftp

At the end of /etc/ssh/sshd_config

Match User newuser
  PasswordAuthentication yes

Restart SSH

$ sudo service ssh restart

Try and SFTP in.

To change new user’s password.

$ sudo passwd newSFTPuser

References

https://askubuntu.com/questions/134425/how-can-i-chroot-sftp-only-ssh-users-into-their-homes

http://askubuntu.com/a/206376/507748

https://serversforhackers.com/permissions-and-user-management

Generate SSH key

ssh key

Github saves the day

Key with passphrase

With password foobar.

openssl genrsa -aes128 -passout pass:foobar -out privkey.pem 2048
openssl rsa -in privkey.pem -passin pass:foobar -pubout -out key.pub

pem to ssh-rsa

chmod 600 privkey.pem
ssh-keygen -y -f privkey.pem > sshrsa.pub

Cert request

Server key without pass phrase or self assigned cert

openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout myPrivateKey.key -out myCert.pem

RSA Key

openssl rsa -in ./myPrivateKey.key -out myPrivateKey_rsa
chmod 600 ./myPrivateKey_rsa

Public key

ssh-keygen -y -f myPrivateKey_rsa > myPublicKey_rsa.pub

Putty
To convert to PPK, load myPrivateKey_rsa into PuttyGen and export myPrivateKey.ppk

openssl.conf NOT FOUND!
Windows doesn’t save your openssl.conf location.
You need to set it in environment variables.

set OPENSSL_CONF=C:\xampp\apache\conf\openssl.cnf

Cert request reference

RSA Key reference

Azure Reference

#ssh