Tag: ssh

Debian

How to setup SSH keys

Create RSA Key Pair ssh-keygen -t rsassh-keygen -t rsa Create .ssh folder mkdir ~/.sshmkdir ~/.ssh Set right permissions chmod 700 ~/.sshchmod 700 ~/.ssh Create authorized_keys file touch ~/.ssh/authorized_keystouch ~/.ssh/authorized_keys Set right permissions chmod 600 ~/.ssh/authorized_keyschmod 600 ~/.ssh/authorized_keys Add public key to the authorized_keys cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keyscat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys

Debian

Hardening SSH on Debian

Open a terminal Open file /etc/ssh/sshd_config sudo nano /etc/ssh/sshd_configsudo nano /etc/ssh/sshd_config Change the listen port Port 65002Port 65002 Deny root Login PermitRootLogin noPermitRootLogin no Make sure that users with empty passwords are not allowed to login to the system PermitEmptyPasswords noPermitEmptyPasswords no Allow certain users to have access via ssh AllowUsers user1 user2AllowUsers user1 user2 …

Microsoft Windows, Security, SSH, Tunneling

Encrypt your internet traffic in Windows via SSH Tunnel

1. Download and install Cygwin – http://www.cygwin.com/ 2. Install Openssh and Vim packets. 3. Open the Cygwin terminal. 4. Type: vim tunnel.shvim tunnel.sh 5. Write in file the following line: ssh -x -2 -D 1919 [username]@[ipaddress-or-hostname]ssh -x -2 -D 1919 [username]@[ipaddress-or-hostname] 6. Exit vim. 7. Type: chmod u+x tunnel.shchmod u+x tunnel.sh to make the script …

Linux, Python

SSH authentication with Python and paramiko

paramiko home page SSH2 protocol for python.   import os import paramiko import sys   try: ssh = paramiko.SSHClient() paramiko.util.log_to_file("./errors.log") ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.load_host_keys(os.path.expanduser(os.path.join("~", ".ssh", "known_hosts"))) ssh.connect(’myserver.com’, username=’user_name’, password=’pass_word’) ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_command(’ls /home/username/’) print "outputn", ssh_stdout.read() error = ssh_stderr.read() print "errorsn", error, len(error) except Exception, e: print "username or password is wrong or the server …