Multiple SSH keys from Windows client to multiple servers [closed] - windows

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 1 year ago.
Improve this question
A lot of people here seem to have the same issue, but with Github.
I don't think that is my issue.
I am fairly new to this so I apologize if this is a duplicate question or if this is a stupid question.
I manage multiple ubuntu servers and I access them from my Windows computer.
I am currently attempting to have ssh keys for all of the servers I have, but it seems like I cannot change the name of the RSA keys or directories. If I do that, the terminal asks me for a password.
Here's what I did:
In my server:
mkdir ~/.ssh && chmod 700 ~/.ssh
On my windows machine:
ssh-keygen -b 4096
Prompts me:
Enter file in which to save the key (C:\Users\Me/.ssh/id_rsa):
Which I enter:
C:\Users\Me\.ssh\server1\server1_rsa
scp C:\Users\me\.ssh\server1_rsa.pub server#serverip:~/.ssh/authorized_keys
(I want to have different directories or something to seperate the SSH keys)
Maybe something like this?
/.ssh
/server1
server1 pub
-erver1 priv
/server2
server2 pub
server1 priv
or maybe even
/.ssh
server1 pub
server1 priv
server2 pub
server2 priv
But this doesnt work.
Any suggestions?

Solution from .ssh/config file for windows (git)
Create a file called "config" in C:\Users\Me.ssh
(no file extension)
Then add the following information per key/server
Host server1ip
User user
Port port
IdentitiesOnly=yes
PreferredAuthentications publickey
PasswordAuthentication no
# CMD
IdentityFile C:\Users\[User]\.ssh\[name_of_PRIVATE_key_file]
# BASH
IdentityFile /c/Users/[User]/.ssh/[name_of_PRIVATE_key_file]

I am sorry if this answer is not making you happy, but I think it will solve your problem :). There is a post on stackoverflow, where you have to add the keys to your ssh-agent.
Kind regards
.ssh/config file for windows (git)

Related

How to execute a scp command inside an ssh session? [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 4 years ago.
Improve this question
How to copy a file located locally in my folder, while being connected in SSH?
This command works perfectly, but only when I run it locally:
scp /home/josh/Desktop/DATA/import/file001.csv root#10.0.3.14:/var/www/html/project
I would like to have the same result in launching it by being connected in ssh, is it possible?
You can setup ControlMaster in your .ssh/config
ControlMaster auto
ControlPath ~/.ssh/control:%h:%p:%r
Then use ssh command mode which will reuse existing connection:
Solution with push ssh session into background:
local$ ssh remote
remote$ ~^Z # Shift+`, Ctrl+z - Push ssh into background
local$ scp file remote:/remotepath
local$ fg
remote$
You can also to open tunnel via:
remote$ ~C # Shift+`, Shift+c - Enter command mode
ssh> -R15000:localhost:22 # tunnel to local:22 from remote:15000
Forwarding port.
remote$ scp -P15000 localhost:/filepath ~/
remote$ ~C
ssh> -KR15000
Canceled forwarding.
remote$
STEP 1 : Get the ip address
hostname -I
STEP 2 : Call SCP into SSH
scp josh#my_ip_address:~/Desktop/DATA/import/file001.csv /var/www/html/project
ie: "josh" is my name for the connection into my PC

SCP username with colon [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 5 years ago.
Improve this question
In order to log into a dedicated server via SSH, i use the following command:
ssh -p 49276 myusername:1001#server.address.net.com
The :1001 after the username is required for me to log in.
I'm now trying to scp some files from this server, using the following command:
scp -P 49276 myusername:1001#server.address.net.com:/var/www /localfolder
But when I do that, I get an error:
Could not resolve hostname myusername: nodename nor servname provided, or not known
I assume it's because of that colon after my username. How would I SCP using these credentials?
This is simply a feature of the Cisso ssh server implementation; it
parses the user name, and if it contains a :[0-9]+ component then it
understands it has to connect the session to the console port with the
corresponding number.
From here https://unix.stackexchange.com/questions/187658/integer-after-username-in-openssh-client-separated-by-colon
Try this:
scp -P 49276 -o User=myusername:1001 server.address.net.com:/var/www /localfolder
This might be a convoluted method, but I believe it will work for your case.
You can define hosts in your ~/.ssh/config file. There you can specify a username to use for a specific hostname. For example -
Host myhostname
User myusername:1001
HostName myhostname.com
Port 49276
With this in your ~/.ssh/config file, you'll be able to use an scp command similar to this -
scp myhostname:/var/www /localfolder
The host will be used together with the specified user and ports in the config file.
A pretty old link, but still useful info on ssh config files:
http://nerderati.com/2011/03/17/simplify-your-life-with-an-ssh-config-file/

How to open putty using batch and login then execute list of commands on bash [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 6 years ago.
Improve this question
I have a Sun OS server with oracle configured on it ; with database 11g i want to take backup , now am connecting to terminal using ssh on putty console but , what i need is finding a way to make it possible to connect using batch to ssh to the server then login then login to oracle then take the backup, is that possible and how.
If you really want to use putty to do this you can use the below in your command prompt in Windows(this will open the putty and its terminal and execute the passed argument in you text file):
putty.exe plink -ssh -load profileName -l username -pw password -m commandPath -t
Or
putty.exe -ssh username#ip -pw password -m commandPath
e.g:
putty.exe -ssh rootz#10.10.10.10 -pw rootzpass -m c:\commands\mycommands.txt
Where profileName is the profile saved in putty and the commandPath is your local directory text file containing the commands you want to execute and the username is the server user and ip is the IP address for the server , the password is your server password then you can put whatever commands you want in your textFile.
Reference
the.earth putty documentation

How can I transfer a file after having already logged in to a server via ssh? [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
This is a rather odd and embarrassing situation for all involved.
Suppose someone (cough cough not me cough cough) accidentally chmod 000d my home directory on a remote server.
I had been using ssh keys to login, since I figured I would forget the actual password on the remote host (which I have). However, now that my home directory has 000 perms, the ssh key in ~/.ssh/authorized_keys is unreadable, and ssh forces me to put in a password that I have long since forgotten.
Also, I don't have sudo superpowers on the remote server.
HOWEVER, I happen to have an ssh session open to the remote server that started before someone (cough) chmod 000d my home directory.
All of this happened while I was trying to upload some files from my local host to a publicly accessible directory in my home directory.
CAN I STILL UPLOAD FILES FROM MY LOCAL MACHINE TO THE REMOTE MACHINE WITHOUT NEEDING A NEW SSH SESSION?!
I figure I could at least put them in /tmp or something for now.
Yes you can!
Press enter,~,Shift+C to open a ssh command line.
Enter -L 12345:localhost:12345 to forward a new port over your existing SSH connection
Run nc -l -p 12345 | tar xzv on your remote ssh session
Run tar czv FileOrDir1 FileOrDir2 Etc | nc localhost 12345 on your local system.
The files will now transfer over your existing ssh connection, and will appear in the current dir of your remote session.
Why you would want to do this instead of just chmod 711 ~ is beyond me though.

Windows public ssh key on remote linux [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
I have public ssh key created on Windows 7 and I want to install it on remote Debian. How to do it?
This question here is off-topic and will probably be moved to http://serverfault.com.
However, copy your public key to the remote debian system with scp (I don't have a Windows machine, so I will give you Linux instruction, try to understand them and modify them according to your operative system):
scp /path/to/public/key.pub user#debian-server:~/.ssh/key.pub
It will ask your password to log in, then it will copy the key and log out.
Log in again in your machine with ssh and do the following:
ssh user#debian-server
chmod 700 .ssh
cd .ssh
cat key.pub >> authorized_keys
chmod 600 authorized_keys
exit
Now, you should be able to log in remotely without issuing your password, providing that RSA authentication method is enabled in sshd_config on the debian server.
Note: the chmod part is not worldwide required, but sometimes wrong permission on files and folder will prevent you to correctly login.
You have to store your public key into .ssh/authorized_keys on your debian machine.
You will find the .ssh folder in your home directory if openssh-server is installed.

Resources