I am trying to use ssh however when I try and set it up by typing
ssh - host - config
I get the errot "ssh: Could not resolve hostname -: Name or service not known"
What should I do?
Error is either in server name or in the way you call it!
ssh user#server
Related
I have an alias to a server machine:
alias myserver='user#server'
however, I cannot ssh into it by using the alias:
ssh myserver
ssh: Could not resolve hostname myserver: Name or service not known
the alias is correctly set:
myserver
returns bash: user#server: command not found.
Obviously, it works when I do it extensively:
ssh user#server
what is going on? I am pretty sure it has been working until today... But not sure what I changed.
Any help?
you can either have an Alias in your bash configuration which includes the actual ssh command aswell ...
alias myserver='ssh user#myserver'
... or have an alias in your ssh config file.
Host myserver
HostName 10.10.20.20
User user
ssh myserver should work.
A more extensive answer can be found for example here.
Not sure about the alias, but I use ~/.ssh/config:
Host myserver
HostName server
User user
Port 22
Then ssh myserver is just like your alias for ssh user#server.
I am using Git on Windows with Git Bash.
In C:\Users\myuser\.ssh I created a config file, where I declared a host
Host my-host along with some configuration.
The config file has the following content:
Host my-host
User my-username
Hostname my-repo.com
Port 7999
IdentityFile id_rsa
In theory, I should be able to connect to this host from the command line:
ssh my-host.
However, that doesn't happen, if try to run this command from Git Bash, I get:
ssh: Could not resolve hostname my-host: Name or service not known
So how can I make this host visible in Git Bash or in Windows Command Line?
Check port number, 7999 is not usual for ssh
set full path for id_rsa, like ~/.ssh/id_rsa
maybe you should use alias name without "-"
check connection with your parameters without alias, like "ssh -i~/.ssh/id_rsa -p7999 user#host"
check you id_rsa, is it private key?
check rights on folder and file: ~/.ssh - 700, ~/.ssh/config - 600
I want to copy /home/cmind012/m.sh from one system to another system (both system Linux) using shell script.
Command $
scp /home/cmind012/m.sh cmind013:/home/cmind013/tanu
getting message
ssh: cmind013: Name or service not known
lost connection
It seems that cmind013 is not being resolved, I would try using first
nslookup cming013
and see what why donesn't it resolve.
It seems that you are missing the IP Address/Domain of the remote host. The format should be user#host:[directory]
You could do the following:
scp -r [directory/files] [remote host]:[destination directory]
ex: scp -r /var/www/html/* root#192.168.1.0:/var/www/html/
Try the following command:
scp /home/cmind012/m.sh denil#172.22.192.105:/home/denil/
The scenario is like:
SERVER_A="servera.com"
SERVER_A_UNAME="usera"
SERVER_B="serverb.com"
SERVER_B_UNAME="userb"
I want to write a shell script which will fist connect to server A, and then only it would be connected to server B. Like:
#!/bin/sh
ssh $SERVER_A_UNAME#$SERVER_A ...and then
ssh $SERVER_B_UNAME#$SERVER_B
But I am not able to do it. It does connect to server A only. How can I achieve it?
You may be able to find some help with this previous question:
How to use bash/expect to check if an SSH login works
Depending on your situation you might also to execute an remote ssh command and wait for positive feedback.
See:
How to use SSH to run a shell script on a remote machine?
you should have a look at ssh ProxyCommands that lets you do indirect connects automatically. basically you put the following in you .ssh/config
Host gateway1
# nichts
Host gateway2
ProxyCommand ssh -q gateway1 nc -q0 gateway2 22
Host targethost
ProxyCommand ssh -q gateway2 nc -q0 targethost 22
and then you can run ssh targethost successfully even if targethost is not reachable directly. you can read more about this e.g. here http://sshmenu.sourceforge.net/articles/transparent-mulithop.html
I installed Git-1.7.9-preview20120201.exe, and when I try to access my repository via SSH it failed.
I investigated and found that if I run SSH -T git#myrepo.com, SSH doesn't load ~/.ssh/config where a custom port is defined.
When I try SSH -F c:\users\tomas\.ssh\config git#myrepo.com everything is OK.
I used Process Monitor and found that SSH is trying to find \\\\.ssh\config here C:\Windows\CSC\v2.0.6\namespace\.ssh.
Why?
How I can force it to use normal path? %HOMEPATH%\.ssh\config?
set the HOME environment variable pointing to %USERPROFILE% for ssh to pick it up. This usually seems to be the problem for many unix solutions that run on windows.
Fast access to set user env variables:
Start > Type "env" > Select "Environmental variables for your account"
I found that windows msygit port store ssh config here <installPath>\Git\etc\ssh\ssh_config