How I set up new machines | Setting ssh keys and shell
Losing access to your ssh key is one of the most dreadful situations for a developer. You will spend your full day creating the new ssh key getting the access to all machines back after you create this new ssh key.
Creating a config for handling access to all the boxes
2. Prologue (I have been using the same ssh key since this long)
3. How I have been using the same ssh key?
4. Allowing ssh into Ubuntu Device
5. Allowing ssh into MAC machine
6. Getting a combination of iTerm and zsh
Host stage User ubuntu HostName 10.X.X.X Host stage-job-box User ubuntu HostName 172.X.X.X IdentityFile ~/new.pem Host my-project User ubuntu HostName 13.X.X.X Host my-project-jobs User ubuntu HostName 3.X.X.X
id_rsa.pemfile to connect to the boxes unless you specify other
IdentityFilewith the path of the
privatekey file. Finally, you can ssh into the boxes using the command,
ssh stageThere are a lot of options which you can use to power this config file. Let me know in the comments section what other options you use.
Prologue (I have been using the same ssh key since this long)I have been using the same ssh key for a while now. In between this time, I have faced a few challenges of changing jobs, SSD crashing a few times some random issues. Even after all those situations, the ssh key that I have used has never changed.
How I have been using the same ssh key?So, I have an old laptop that I keep at my place which contains the ssh key which I use for almost all the purposes. Note: We do have one more layer of security which involves VPN being connected to connect every box related to my current organization. Whenever I get a new machine, I get back to the same machine and
sshinto this old machine and get all of the required data from that machine using a combination of
Allowing ssh into Ubuntu DeviceFor
sshing into any machine, you need to open the port 22 of that machine. As that machine is a ubuntu machine, The simplest way is to install OpenSSH onto the Ubuntu machine. Use the following command in Ubuntu.
sudo apt install openssh-server -yWhile in the ubuntu machine try to run
ifconfigto find out the
IPof the machine on which you are on. Make sure that both of the machines are on the same wifi. Once you are get the
IPof the machine that you are looking for, find the
scpcommand that suites you. One of my friend has written a good post for SCP commands. We will use one of those commands to get the file from that machine to my machine.
scp [email protected]:~/Desktop/ranvir.png ~/Desktop/.This will get the file from the given machine and dump the file in the
Allowing ssh into MAC machineSomething similar is applied to MAC devices as well. For allowing ssh into MAC devices you have to allow
remote loginon the device which you want to access. You can find the setting in
preferences -> sharing. After this, you can
sshinto the machine and
scpinto the new device to get the required files.
Getting a combination of iTerm and zshI have a MAC machine for development and love to use
zshfor powering my shell. Their command completion is very useful while programming and help us find the commands more easily. You can directly download
iTermfrom their website.
ZSHis used to provide good visual touch to your system. I love the default shell theme they provide. Currently, you use the software by downloading using
curl. Head to their website for more details.
zshalso adds some git aliases, which makes your life far easier as a developer. Hope you liked this post. Please subscribe to the weekly newsletter by sharing your email.
Did you enjoy reading or think it can be improved? Don’t forget to leave your thoughts in the comments section below! If you liked this article, please share it with your friends, and read a few more!