Login into Clients server with theire rsa key [closed] - ssh

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
A client gave me a rsa and ppk file so I can log into their server. Im using OSX Lion and I have all my current server connections in my id_rsa file. How do I add their key so I can login with that?

If the RSA file they gave you is stored in, say, ~/client/foo_rsa.key, you could:
$ ssh -i ~/client/foo_rsa.key username#theirhost.example.com
Storing this sort of configuration in ~/.ssh/config is also a very good idea if you want a more permanent solution.
In ~/.ssh/config, add:
host clienthost
identityfile client/foo_rsa.key
hostname theirhost.example.com
user usernameonhost
You then connect simply with:
$ ssh clienthost
and the settings from the config file control your session.
The spacing above is unimportant and included only for readabilty. Read man ssh_config for details of other things you can put in this configuration file. There's A LOT of stuff you can do, including proxying your connection through other hosts, creating encrypted tunnels (for other protocols like HTTP or SOCKS) on arbitrary ports, etc.

Related

how do you load an ssh_config file within a cron job [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
ssh_config files allow you to configure an ssh client
You can specify aliases, default users and identity files for different ssh hosts, amongst other things
The docs state that the ssh_config options are loaded magically by the ssh client in the following order:
command line options
user-specific file (~/.ssh/config)
system-wide file (/etc/ssh/ssh_config)
However, these configuration options aren't automatically available/respected within a cron job context
how can you load an ssh configfile such as ~/.ssh/config for a crontab context or in a specific cronjob?
Update:
issue was this: https://superuser.com/questions/508408/public-key-always-asking-for-password-and-keyphrase
ssh --help says that there is a -F configfile option. However, I think ssh should still be checking in ~/.ssh/config and /etc/ssh/ssh_config, even when run via cron.
When run from cron, the HOME environment variable is set to point to your normal home directory, so ssh has all the information it needs to locate the standard configuration files.
I tested this by putting the following cron job in place:
* * * * * strace -o /tmp/trace -f -s 80 ssh localhost uptime > /tmp/trace
And inspecting /tmp/trace after the job has run, I see:
29079 open("/home/lars/.ssh/config", O_RDONLY) = 3
29079 open("/etc/ssh/ssh_config", O_RDONLY) = 3
Update
On my OS X machine (OS X 10.10.3), I set up the following ~/.ssh/config file:
Host stackoverflow
Hostname fileserver.house
IdentityFile fileserver_rsa
I created the following cron entry:
* * * * * ssh stackoverflow uptime > $HOME/output
The only way that would work would be if ssh were reading my ~/.ssh/config file...and it works just fine. What leads you do believe that things aren't working?

SSH tunnel with rsa identity without passphrase [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I created key pair by command
ssh-keygen -t rsa -N "" -f "C:\ssh2\id_rsa"
After I tried to connect to remoted server by command
ssh -2 -Nv -L 81:192.168.45.12:8989 proxy#host.ru -p 10022 -i "C:\ssh2\id_rsa"
And all finished that server required passphrase
Enter passphrase for key 'C:\ssh2\id_rsa':
But I created key pair without passphrase (-N ""). Why does it require passphrase?
The command issued specified "" - an empty string! - as the passphrase, not generation with no passphrase. (Simply hit "enter" when prompted for the passphrase and viola!)
To generate a key without any passphrase, do not specify the optional -N (passphrase) option when creating a new key or when requesting to change the passphrase (see -p) ..
.. and may the foil-hat gnomes be merciful to you.
I understand that connection happen, but if I click Enter button, console write me
debug1: No more authentification methods to try
Permission denied (publickey, hostbased)

SSH config file paragraph to open a specific directory on remote server [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Is there a way to specifically ssh into a particular directory in remote location, specifically using the local ssh config file (not terminal)? Something like Dir option in the paragraph below, for example,
Host remote_dir
Hostname remote_server
User username
Dir path/to/remote_dir/
So, if I, ssh using the Host value from above paragraph,
ssh remote_dir
Then, I would like to be logged in and the terminal to be ready for me at path/to/remote_dir/ of the remote server,
username#remote_server: path/to/remote_dir/ > pwd
/home/username/path/to/remote_dir/
In this post on ServerFault, they say you can't do it all through the ssh config file. But you can do it with the ssh config and your .bash_profile or whatever the terminal nerds call it.
in the ssh config file add
Host dev
Hostname server.com
User joe
then in your .bash_profile add an alias
alias domain1="ssh dev -t 'cd domains/domain1; bash'"
Here the dev refers to what you set up in the config file.
In the Terminal, just type domain1, you will be asked to put in your password and will go straight to the directory. Make a new alias for all your domains and it will make logging in to each one super easy.
Take a look at
https://serverfault.com/questions/167416/change-directory-automatically-on-ssh-login
This is the accepted answer:
LocalCommand isn't what you want, anyway. That's run on your machine. You want RemoteCommand. Something like this worked for me:
Host example.net
RemoteCommand cd / && exec bash --login
RequestTTY yes
(Old answer) For a similar use case, ssh -t is also an option:
ssh server -t "cd /my/remote/directory; bash --login"
It is not the same, as it does not use ssh config. But you can define an alias for the command and end up with a similar effect.

enable root log-in in Ubuntu Server 12.04 [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
How do I enable root login to an Ubuntu Server 12.04?
That is, to be able to ssh as root. I can only login now as a regular user.
Thanks
Make sure you have set a root password (sudo su passwd)
Depending how your ssh is installed, you usually need to edit /etc/ssh/sshd_config and change "PermitRootLogin no" to "PermitRootLogin yes"
Edit /etc/ssh/sshd_config and add the following line:
PermitRootLogin yes
You really shouldn't allow direct SSH login as root. It's a pretty major security risk. See http://www.cyberciti.biz/tips/openssh-deny-or-restrict-access-to-users-and-groups.html
Why not log in as a user with sudo privileges then do 'sudo bash' or 'sudo sh'
This site explains a bit more: https://askubuntu.com/questions/57040/what-is-the-difference-between-su-sudo-bash-and-sudo-sh
If you really must enable ssh as root the first link should give you the info you need to configure OpenSSH assuming that's the server you're using.
You'll have to set a root password too, this site should help: https://help.ubuntu.com/community/RootSudo#Enabling%20the%20root%20account

How do I ssh two deep with private keys? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
At work, I can ssh to a server with private keys set up on my work machine.
jake#work$ ssh server
jake#server$
I'm trying to ssh from home to work to server with the private keys. The process should look like this:
jake#home$ ssh work
jake#work$ ssh server
jake#server$
But instead its asking me for a password. If I call ssh server with -v, it shows that its looking for keys .ssh/id_dsa and .ssh/id_rsa but my key is named differently.
I can get into server by specifying the key myself:
jake#home$ ssh work
jake#work$ ssh server -i .ssh/idfoo
jake#server$
How do I get ssh to find the right keys for this two step login process?
You can specify the key using Host+IdentityFile in your ~/.ssh/config on work:
Host server
IdentityFile idFoo
Or just this alone in the config file, to apply a key identity to all sessions:
IdentityFile idFoo
But I can't explain why this is required only when trying to ssh from work->server from a work ssh session.