background preloader

SSH

Facebook Twitter

SSH public keys. From Noah.org SSH Key Generation Overview with no password This shows how to use unencrypted public keys for logging in to a remote SSH server without a password.

SSH public keys

The basic steps are: Create an RSA key-pair with an empty password (no encryption). Copy the public key to the remote server. Here are those steps as you would actually type them (`ssh-copy-id` does steps 2 and 3): ssh-keygen -q -t rsa -N '' -f ~/.ssh/id_rsa ssh-copy-id user@remote.example.com Here is what you would do without `ssh-copy-id`. Ssh-keygen -q -t rsa -N '' -f ~/.ssh/id_rsa scp ~/.ssh/id_rsa.pub user@remote.example.com:/tmp/id_rsa.pub ssh user@remote.example.com "mkdir -p ~/.ssh;chmod 700 ~/.ssh;touch ~/.ssh/authorized_keys;cat /tmp/id_rsa.pub >> ~/.ssh/authorized_keys" Usually it's bad to use unencrypted public keys for logging in to remote servers without a password. The `ssh-copy-id` Script OpenSSH comes with `ssh-copy-id` which makes it much easier to setup your local host to connect to a remote server via SSH. SSH login without password.

Your aim You want to use Linux and OpenSSH to automize your tasks.

SSH login without password

Therefore you need an automatic login from host A / user a to Host B / user b. You don't want to enter any passwords, because you want to call ssh from a within a shell script. How to do it First log in on A as user a and generate a pair of authentication keys. A@A:~> ssh-keygen -t rsa Generating public/private rsa key pair. Now use ssh to create a directory ~/.ssh as user b on B. A@A:~> ssh b@B mkdir -p .ssh b@B's password: Finally append a's new public key to b@B:.ssh/authorized_keys and enter b's password one last time: a@A:~> cat .ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys' b@B's password: From now on you can log into B as b from A as a without password: a@A:~> ssh b@B hostname B A note from one of our readers: Depending on your version of SSH you might also have to do the following changes: Keywords: ssh openssh password Author: Mathias Kettner. SSH Can Do That? Productivity Tips for Working with Remote Servers.

SSH has many features which are helpful when working regularly with files on remote servers; together they can give a vast increase in productivity over the bare use of SSH.

SSH Can Do That? Productivity Tips for Working with Remote Servers

If you regularly use SSH, it’s worth spending a little time learning about these and configuring your environment to make your life easier. This has been presented at presented at Yapc Europe 2011 in Riga and the Floss UK Spring 2012 Conference in Edinburgh. If you’d like me to come and talk about this at your user group or workplace, please get in touch. Multiple Connections Often it’s useful to have multiple connections to the same server, for example to edit a file, run some file-system commands, and view a log file all in different terminal windows.

Fortunately OpenSSH has a feature which makes it much snappier to get another terminal on a server you’re already connected to: connection sharing. ControlMaster auto ControlPath /tmp/ssh_mux_%h_%p_%r What About Windows Users? Copying Files Repeated Connections. ISC diary: SSHD root kit in the wild : linux. Copy your ssh public key to a server from a machine that doesn't have ssh-copy-id.