Skip to content

Instantly share code, notes, and snippets.

@sebastianneubert
Last active August 29, 2015 14:24
Show Gist options
  • Save sebastianneubert/a54bcc4f025b821e386c to your computer and use it in GitHub Desktop.
Save sebastianneubert/a54bcc4f025b821e386c to your computer and use it in GitHub Desktop.
SSH Config

Configure ssh config for shortcuts

file: ~/.ssh/config

Host ela
    HostName ela-webdev.local
    Port 22
    User develop

Call it with:

ssh ela

Use public keys to accept connections without password

Copy public key from the client to the remote host to the file ~/.ssh/authorized_keys and change the file permissions to 644 to avoid password input.

scp ~/.ssh/id_rsa.pub user@remotehost:~/.ssh/authorized_keys
ssh user@remotehost chmod 644 ~/.ssh/authorized_keys

Call remote operations via ssh

targethost="www.domain.xxx";
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@$targethost '
	cd /tmp;
	if [ -d "'$tmpdir'" ]; then rm -rf '$tmpdir'; echo "remove tempdir on remote: '$tmpdir'"; fi;
	if [ -e "'$tmpfile'" ]; then rm '$tmpfile'; echo "remove tempfile on remote: '$tmpfile'"; fi;
';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment