ssh interview questions
Top ssh frequently asked interview questions
I'm working on Ubuntu and want to use multiple private keys to connect to different servers or different portions of the same server (My uses are admin of server, admin of git, and normal git usage within the same server). I tried simply stacking the keys in the id_rsa
files to no avail.
Apparently the way to do this is use the command ssh -i <key location> login@server.com
. That is quite cumbersome.
Any suggestions as to how to go about doing this a bit easier?
Source: (StackOverflow)
In git, how I can add a remote origin when my host use a different ssh port?
git remote add origin ssh://user@host/srv/git/example
Source: (StackOverflow)
I set a passphrase when creating a new SSH key on my laptop. But, as I realise now, this is quite painful when you are trying to commit (Git and SVN) to a remote location over SSH many times in an hour.
One way I can think of is, delete my SSH keys and create new. Is there a way to remove the passphrase, while still keeping the same keys?
Source: (StackOverflow)
I am running into this error of:
$ git push heroku master
Warning: Permanently added the RSA host key for IP address '50.19.85.132' to the list of known hosts.
! Your key with fingerprint b7:fd:15:25:02:8e:5f:06:4f:1c:af:f3:f0:c3:c2:65 is not authorized to access bitstarter.
I tried to add the keys and I get this error below:
$ ssh-add ~/.ssh/id_rsa.pub
Could not open a connection to your authentication agent.
Source: (StackOverflow)
A rather unusual situation perhaps, but I want to specify a private SSH-key to use when executing a shell (git) command from the local computer.
Basically like this: git clone git@github.com:TheUser/TheProject.git -key "/home/christoffer/ssh_keys/theuser"
Or even better (in Ruby):
with_key("/home/christoffer/ssh_keys/theuser") do
sh("git clone git@github.com:TheUser/TheProject.git")
end
I have seen examples of connecting to a remote server with Net::SSH that uses a specified private key, but this is a local command. Is it possible?
Source: (StackOverflow)
Could you please suggest me how to run a shell script on remote machine?
I have ssh configured on both machine A and B. My script is on machine A which will perform a task on machine B.
Source: (StackOverflow)
I have a Ubuntu VM running on my Windows 7 machine. How do I set it up so that I can access an the webserver externally through ssh?
I found steps (in Setup SSH access between VirtualBox Host and Guest VMs) to be able to ssh to my guest from my host, but that still leaves me with the problem of accessing it through my router.
I suppose that I could install an ssh server on my Windows machine and then tunnel a few times (though I'm not 100% sure what to use in terms of local, dynamic, etc. or how to set up multiple tunnels?), but is there a way to make the VM directly accessible to my router so I could directly port forward to it?
Source: (StackOverflow)
This is probably a stupidly simple question to some :)
I've created a new linux instance on Amazon EC2, and as part of that downloaded the .pem file to allow me to SSH in.
When I tried to ssh with:
ssh -i myfile.pem <public dns>
I got:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for 'amazonec2.pem' are too open.
It is recommended that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: amazonec2.pem
Permission denied (publickey).
Following this post I tried to chmod +600 the pem file, but now when I ssh I just get:
Permission denied (publickey).
What school-boy error am I making here?
The .pem file is in my home folder (in osx). It's permissions look like this:
-rw-------@ 1 mattroberts staff 1696 19 Nov 11:20 amazonec2.pem
Source: (StackOverflow)
My vagrant was working perfectly fine last night. I've just turned the PC on, hit vagrant up
, and this is what I get:
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Error: Connection timeout. Retrying...
default: Error: Connection timeout. Retrying...
default: Error: Connection timeout. Retrying...
default: Error: Connection timeout. Retrying...
default: Error: Connection timeout. Retrying...
default: Error: Connection timeout. Retrying...
default: Error: Connection timeout. Retrying...
default: Error: Connection timeout. Retrying...
default: Error: Connection timeout. Retrying...
default: Error: Connection timeout. Retrying...
default: Error: Connection timeout. Retrying...
default: Error: Connection timeout. Retrying...
default: Error: Connection timeout. Retrying...
Has anyone had this before? vagrant isn't widely covered on the web yet and I can't find a reason why this is occurring.
Source: (StackOverflow)
I need to do the ssh key audit for GitHub, but I am not sure how do find my RSA key fingerprint. I originally followed a guide to do the set up on a ubuntu 10.04 box hosted by linode.
What is the command I need to enter to find my current RSA key fingerprint if I am logged remotely using Putty?
Source: (StackOverflow)
I'm working on a linux machine through SSH (Putty).
I need to leave a process running during the night, so I thought I could do that by starting the process in background (with an ampersand at the end of the command) and redirecting stdout to a file.
To my surprise, that doesn't work. As soon as I close the Putty window, the process is stopped.
How can I prevent that from happening??
Source: (StackOverflow)
When I ssh into my ubuntu-box running Hardy 8.04, the environment variables in my .bashrc are not set.
If I do a source .bashrc, the variables are properly set, and all is well.
How come .bashrc isn't run at login?
Source: (StackOverflow)
I have an EC2 instance running (FreeBSD 9 AMI ami-8cce3fe5), and I can ssh into it using my amazon-created key file without password prompt, no problem.
However, when I want to copy a file to the instance using scp I am asked to enter a password:
scp somefile.txt -i mykey.pem root@my.ec2.id.amazonaws.com:/
Password:
Any ideas why this is happening/how it can be prevented?
Thanks in advance!
Hoff
Source: (StackOverflow)
Recently I've been unable to clone or push to github, and I'm trying to find the root cause.
This is on windows
I have cygwin + git as well as msysgit.
Msysgit was installed with the following options:
- OpenSSH
- Use Git from Windows Command Prompt
That gives me 4 environments to try to use git in:
- Windows cmd prompt
- Powershell
- Git Bash
- Cygwin
Somehow I've managed to get myself into a position where when I try to clone a repository using msysgit, cmd.exe, or Powershell, I get the following error:
> Initialized empty Git repository in
> C:/sandbox/SomeProject/.git/
> @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
> @ WARNING: UNPROTECTED PRIVATE KEY FILE! @
> @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
> Permissions 0644 for
> '/c/Users/Ben/.ssh/id_rsa' are too
> open. It is recommended that your
> private key files are NOT accessible
> by others. This private key will be
> ignored. bad permissions: ignore key:
> /c/Users/Ben/.ssh/id_rsa Permission
> denied (publickey). fatal: The remote
> end hung up unexpectedly
This is using the .ssh folder in my c:\users\ben\ folder, which is what is used by msysgit. I suspect cygwin works because the .ssh folder is located elsewhere, but I'm not sure why
In Git Bash, I check the permissions:
$ ls -l -a ~/.ssh
Which gives me:
drwxr-xr-x 2 Ben Administ 0 Oct 12 13:09 .
drwxr-xr-x 34 Ben Administ 8192 Oct 12 13:15 ..
-rw-r--r-- 1 Ben Administ 1743 Oct 12 12:36 id_rsa
-rw-r--r-- 1 Ben Administ 399 Oct 12 12:36 id_rsa.pub
-rw-r--r-- 1 Ben Administ 407 Oct 12 13:09 known_hosts
These permissions are apparently too relaxed. How they got this way, I have no idea.
I can try to change them...
$ chmod -v -R 600 ~/.ssh
which tells me:
mode of `.ssh' changed to 0600 (rw-------)
mode of `.ssh/id_rsa' changed to 0600 (rw-------)
mode of `.ssh/id_rsa.pub' changed to 0600 (rw-------)
mode of `.ssh/known_hosts' changed to 0600 (rw-------)
But it seems to have no effect. I still get the same error, and doing
$ ls -l -a ~/.ssh
yields the same permissions as before.
UPDATE:
I tried to fix the permissions to those files in cygwin, and cygwin reports their permissions correctly, gitbash does not:
Any ideas on how I can really fix these permissions?
Source: (StackOverflow)
I have a private key protected with a password to access a server via SSH.
I have 2 linux (ubuntu 10.04) machines and the behavior of ssh-add command is different in both of them.
In one machine, once I use "ssh-add .ssh/identity" and entered my password, the key was added permanently, i.e., every time I shutdown the computer and login again, the key is already added.
In the other one, I have to add the key every time I login.
As far as I remember, I did the same thing on both. The only difference is that the key was created on the one that is added permanently.
Does anyone know how to add it permanently to the other machine as well?
Source: (StackOverflow)